refactor(ini): Simplify token related INI code#2596
refactor(ini): Simplify token related INI code#2596xezon merged 9 commits intoTheSuperHackers:mainfrom
Conversation
|
| Filename | Overview |
|---|---|
| Core/GameEngine/Include/Common/INI.h | Core INI class header: separator fields removed and replaced with static inline methods; copy/assignment protected via CPP_11(= delete); getNextToken/getNextTokenOrNull/getNextSubToken made static; trivial destructor declaration removed. |
| Core/GameEngine/Source/Common/INI/INI.cpp | INI.cpp: constructor no longer initialises removed separator members; empty destructor body removed; null-seps guard removed from getNextToken/getNextTokenOrNull; parseSoundsList converted to constexpr + for-loop; minor token != nullptr → token cleanup throughout. |
| Generals/Code/GameEngine/Source/GameLogic/Object/ObjectCreationList.cpp | parseDebrisObjectNames: variable renamed from debrisName to token; pre-existing double-advance preserved (acknowledged, separate PR incoming). |
| Generals/Code/GameEngine/Source/GameLogic/Object/Update/AutoDepositUpdate.cpp | parseUpgradePair: getNextTokenOrNull+manual null-check replaced with getNextToken (which throws on null — same exception type, equivalent behavior). |
| GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/OCLUpdate.cpp | parseFactionObjectCreationList: same getNextTokenOrNull+null-check → getNextToken refactor as AutoDepositUpdate. |
| Generals/Code/GameEngine/Include/Common/BitFlagsIO.h | BitFlags::parse: token != nullptr → token in loop condition, no functional change. |
Class Diagram
%%{init: {'theme': 'neutral'}}%%
classDiagram
class INI {
-INI(const INI&) = delete
-INI& operator=(const INI&) = delete
+INI()
+isEOF() bool
+getFilename() AsciiString
+getLoadType() INILoadType
+getLineNum() UnsignedInt
+getSeps()$ const char*
+getSepsPercent()$ const char*
+getSepsColon()$ const char*
+getSepsQuote()$ const char*
+getEndToken()$ const char*
+getNextToken(seps)$ const char*
+getNextTokenOrNull(seps)$ const char*
+getNextSubToken(expected)$ const char*
+initFromINI(what, parseTable) void
+initFromINIMulti(what, parseTableList) void
-m_readBuffer char*
-m_readBufferUsed unsigned
-m_filename AsciiString
-m_loadType INILoadType
-m_lineNum UnsignedInt
-m_buffer char[]
-m_endOfFile Bool
}
note for INI "Separator strings removed as member fields;\nnow returned by static inline methods.\ngetNextToken/OrNull/SubToken also made static."
Reviews (5): Last reviewed commit: "Merge branch 'main' into ini_small_refac..." | Re-trigger Greptile
A handful of miscellaneous changes to the INI code. Should have zero change in behavior.
Generals and Zero Hour code are not separated, but the commit diffs are pretty clean.