Raised This Month: $40 Target: $400
 10% 

[INC] NestedStringMap - StringMaps.. But with nesting


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Kinsi
Senior Member
Join Date: Apr 2013
Old 01-16-2018 , 01:46   [INC] NestedStringMap - StringMaps.. But with nesting
Reply With Quote #1

Had the idea to do this for a while, came around to do it today because i happened to be reminded of it and was bored.

Example:

PHP Code:
        //Create a nested stringmap object with enabled Iteration
    
NestedStringMap topLevel = new NestedStringMap(true);
    
    
//Child does not exist yet, will be created, written into the parent, and returned
    
NestedStringMap child topLevel.Child("firstChild");
    
    
//Creates a sub-child in the created child, and sets the value of SomeKey to 1337
    
child.Child("child1").SetValue("SomeKey"1337);
    
    
//Retrieves the set key from the created sub-child
    
LogMessage("Read: %i"child.Child("child1").GetAndReturnValue("SomeKey"));
    
    
//Creates some more sub-childs because why not. We'll disable Iteration for these, 
    //thus no ArrayLists will be created / maintained alongside of them.
    
child.Child("child2"Iterator_Disable);
    
child.Child("child3"Iterator_Disable);
    
    
//iterating over the children of the first child-NestedStringMap
    
NestedStringMapChildren NSMC;
    
    if(
child.GetIterator(NSMC)) {
        for(
int i 0NSMC.Lengthi++) {
            
char childName[255];
            
            
NestedStringMap x view_as<NestedStringMap>(NSMC.GetChild(i));
            
            
x.GetName(childNamesizeof(childName));
            
            
LogMessage("Child %i in NestedStringMap %i has name %s"ichildchildName);
        }
    }
    
    
//Retrieve the sub-child from the child, go back to its parent again and close that.
    //Yes, it essentially is no different than "child.Close()";
    //Calling Close() will take care of also closing any possibly nested children
    
child.Child("child3").Parent().Close();
    
    
//Finally close the top level NestedStringMap
    
topLevel.Close(); 
Source: https://github.com/kinsi55/NestedStringMap

Have ideas for things to implement? PR them.

HF bois
Attached Files
File Type: inc NestedStringMap.inc (9.3 KB, 77 views)
File Type: sp Get Plugin or Get Source (NestedStringMapExample.sp - 73 views - 1.9 KB)
__________________
Battle Royale in CS:GO done properly - http://Go4TheKill.net

Last edited by Kinsi; 01-18-2018 at 02:01.
Kinsi is offline
RumbleFrog
AlliedModders Donor
Join Date: Dec 2016
Location: US
Old 01-16-2018 , 01:56   Re: [INC] NestedStringMap - StringMaps.. But with nesting
Reply With Quote #2

Ay, thanks for implementing my request. Time to make something stupid.
RumbleFrog is offline
Kinsi
Senior Member
Join Date: Apr 2013
Old 01-18-2018 , 01:09   Re: [INC] NestedStringMap - StringMaps.. But with nesting
Reply With Quote #3

Update: Added iterator support.
__________________
Battle Royale in CS:GO done properly - http://Go4TheKill.net
Kinsi is offline
ThatKidWhoGames
Senior Member
Join Date: Jun 2013
Location: IsValidClient()
Old 05-21-2018 , 14:57   Re: [INC] NestedStringMap - StringMaps.. But with nesting
Reply With Quote #4

Thanks for this!!
__________________


I take custom plugin requests, add me on Steam for details.
ThatKidWhoGames is offline
Reply


Thread Tools
Display Modes

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 22:49.


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