From 58d0b883d3926add8a2810e1df8bcfe51220d0de Mon Sep 17 00:00:00 2001 From: msojocs Date: Mon, 3 Jul 2023 22:55:30 +0800 Subject: [PATCH] feat: NameAllocator::GetNextName --- src/include/wxml.h | 7 +++---- src/wxml/name_allocator.cpp | 20 ++++++++++++++------ 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/src/include/wxml.h b/src/include/wxml.h index a1df025..553c0f0 100644 --- a/src/include/wxml.h +++ b/src/include/wxml.h @@ -28,8 +28,9 @@ namespace WXML { private: /* data */ - std::string offset_1; // v5 - std::string offset_7; // v4 + int offset_0 = 0; + std::string offset_4; + std::string offset_28; public: std::string ALPAHBET = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"; static int ALPAHBETLEN; @@ -395,8 +396,6 @@ namespace WXML void ATTR(); }; - - }; diff --git a/src/wxml/name_allocator.cpp b/src/wxml/name_allocator.cpp index 3296f31..c96900c 100644 --- a/src/wxml/name_allocator.cpp +++ b/src/wxml/name_allocator.cpp @@ -7,15 +7,23 @@ namespace WXML { { NameAllocator::ALPAHBETLEN = NameAllocator::ALPAHBET.size(); } - this->offset_1.assign(a2); - this->offset_7.assign(a3); + this->offset_4.assign(a2); + this->offset_28.assign(a3); } - - /** - * TODO: - */ + void NameAllocator::GetNextName(std::string & a2) { + std::stringstream ss; + ss << this->offset_4 << this->offset_28[this->offset_0 % this->offset_28.length()]; + int v9 = this->offset_0; + while (v9) + { + ss << WXML::NameAllocator::ALPAHBET[v9 % WXML::NameAllocator::ALPAHBETLEN]; + v9 /= WXML::NameAllocator::ALPAHBETLEN; + } + this->offset_0++; + a2 = ss.str(); + }