Raised This Month: $ Target: $400
 0% 

How to create a tree? (KeyValues re-implementation)


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Dragokas
Veteran Member
Join Date: Nov 2017
Location: Ukraine on fire
Old 04-18-2023 , 16:43   How to create a tree? (KeyValues re-implementation)
Reply With Quote #1

Hi,
does anybody have a ready code to store/access a multilevel tree of strings in memory?

I'd like to re-make KeyValues class by own implementation to finally bypass the Valve bugs, like impossibility to store some Unicode and 'case' issues, like:
PHP Code:
    char str[] = "临死一搏暴雨版/Lighthouse Storm Mode";
    
PrintToServer("Original: %s"str);
    
KeyValues kv = new KeyValues("root");
    
kv.Rewind();
    if (
kv.JumpToKey(strtrue))
    {
        
char buf[128];
        
kv.GetSectionName(bufsizeof(buf));
        
PrintToServer("Current key: '%s'"buf);
    } 
Quote:
Original: 临死一搏暴雨版/Lighthouse Storm Mode
Current key: 'lighthouse Storm Mode'
I have a code to read / write. Now, I need a way for safe/performance store & access the tree.

Perhaprs, StringMap is good, however it cannot hold objects.
I heard something about "Dynamic", but I don't remember link & details.

Any suggestions?

-
References:
[Non-SP] KeyValues parsers
KeyValues Extension
KeyValuesToFile with saving keys with void values
Keyvalues #base <sourcefile>
__________________
Expert of CMD/VBS/VB6. Malware analyst. L4D fun (Bloody Witch & FreeZone)
[My plugins] [My tools] [GitHub] [Articles] [HiJackThis+] [Donate]

Last edited by Dragokas; 04-18-2023 at 16:47.
Dragokas is offline
Dragokas
Veteran Member
Join Date: Nov 2017
Location: Ukraine on fire
Old 04-19-2023 , 11:51   Re: How to create a tree? (KeyValues re-implementation)
Reply With Quote #2

Ok, I found Dynamic from Neuro Toxin, I taked about. It seems it support objects as values. Theoretically, this gives me a chance to create a tree with a linked list through StringMap-s.
__________________
Expert of CMD/VBS/VB6. Malware analyst. L4D fun (Bloody Witch & FreeZone)
[My plugins] [My tools] [GitHub] [Articles] [HiJackThis+] [Donate]
Dragokas is offline
Dragokas
Veteran Member
Join Date: Nov 2017
Location: Ukraine on fire
Old 04-22-2023 , 15:23   Re: How to create a tree? (KeyValues re-implementation)
Reply With Quote #3

Figured out, that StringMap/ArrayList also can hold handles to another StringMap/ArrayList.

Guess, a such structure:

Scheme of emulation of 1st KeyValues key by my KeyValuesW methodmap:
Code:
ArrayList
|
|-[0]=StringMap ->	| (unordered)
|			| Key1 = Value1 (typeof String/Int/Float or another ArrayList handle => 2nd KeyValues key)
|			| Key2 = Value2 ...
|			| Key3 = Value3 ...
|(ordered)
|-[1]=Key1
|-[2]=Key2
|-[3]=Key3
ArrayList can only hold values.
We're using StringMap to be able hold key + value and fast access.
However, StringMap is unordered, so we're mirroring keys to ArrayList as values starting from index 1, where we can enumerate "keys" in correct order.

What do you think? Any additional optimizations possible?
__________________
Expert of CMD/VBS/VB6. Malware analyst. L4D fun (Bloody Witch & FreeZone)
[My plugins] [My tools] [GitHub] [Articles] [HiJackThis+] [Donate]

Last edited by Dragokas; 04-22-2023 at 15:33.
Dragokas is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 16:12.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode