Raised This Month: $79 Target: $400
 19% 

[SP] ConfigMap: StringMap & SMCParser


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
nergal
Veteran Member
Join Date: Apr 2012
Old 11-18-2019 , 20:47   [SP] ConfigMap: StringMap & SMCParser
Reply With Quote #1

presenting ConfigMap which is a StringMap Tree very much similar to KeyValues.

Difference is that it only works with strings as values and stringmaps as sections.


API:
Code:
ConfigMap(const char[] filename);

bool GetVal(const char[] key, PackVal valbuf);

void Destroy();

int GetSize(const char[] key_path);

bool Get(const char[] key_path, char[] buffer, int buf_size);

ConfigMap GetSection(const char[] key_path);

KeyValType GetKeyValType(const char[] key_path);
Accessing values and sections is easy:

assume this config:
Code:
"root" {
    "value1"    "howdy"
    "section1" {
        "value1"    "hi"
    }
    
    "section2" {
        "subsection1" {
            "value1"    "bonjour"
        }
    }
}
to access the value "howdy", use the key path string: "root.value1"
to access the value "hi", use the key path string: "root.section1.value1"
to access the value "bonjour", use the key path string: "root.section2.subsection1.value1"

to reduce having to use these key path strings all the time on frequently used subsections, use `GetSection` to save the ConfigMap of a subsection, there is no need to free the instance to the subsection.

When you're done with the entire config map, use `Destroy` to clean it all up.
Attached Files
File Type: sp Get Plugin or Get Source (cfg.sp - 80 views - 10.3 KB)
__________________

Last edited by nergal; 11-18-2019 at 20:47.
nergal is offline
 


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 00:07.


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