Raised This Month: $7 Target: $400
 1% 

[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 , 00: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, 236 views)
File Type: sp Get Plugin or Get Source (NestedStringMapExample.sp - 212 views - 1.9 KB)
__________________

Last edited by Kinsi; 01-18-2018 at 01:01.
Kinsi is offline
RumbleFrog
Great Tester of Whatever
Join Date: Dec 2016
Location: Fish Tank
Old 01-16-2018 , 00: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 , 00:09   Re: [INC] NestedStringMap - StringMaps.. But with nesting
Reply With Quote #3

Update: Added iterator support.
__________________
Kinsi is offline
ThatKidWhoGames
Veteran Member
Join Date: Jun 2013
Location: IsValidClient()
Old 05-21-2018 , 13:57   Re: [INC] NestedStringMap - StringMaps.. But with nesting
Reply With Quote #4

Thanks for this!!
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 02:38.


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