Raised This Month: $ Target: $400
 0% 

PHP SMC/VDF Parser


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Nikkii
Member
Join Date: Feb 2012
Old 11-07-2012 , 23:09   PHP SMC/VDF Parser
Reply With Quote #1

Wrote this to replace the outdated/ugly parsers that I've found

http://paste.ee/p/mootl (Syntax Highlighted)
http://paste.ee/r/mootl (Raw text)

Examples:
PHP Code:
$reader = new KVReader();
//Reading
print_r($reader->read('"Test" {
    "key" "value"
}'
));
print_r($reader->readFile("filename"));
print_r($reader->readFile("url"));

//Writing
$arr = array(
    
'Test' => array(
        
'key' => 'value'
    
)
);
echo 
$reader->write($arr);
$reader->writeFile('filename'$arr); 
Credits of course to KawMAN's Post for the reader, adapted to use references instead of class specific values, and to the Sourcebans KVReader author for the basics used to write arrays, adapted to write to a string instead of a file, and cleaned up.

Last edited by Nikkii; 11-08-2012 at 01:17.
Nikkii is offline
asherkin
SourceMod Developer
Join Date: Aug 2009
Location: OnGameFrame()
Old 11-08-2012 , 06:50   Re: PHP SMC/VDF Parser
Reply With Quote #2

Is this a KV (VDF) or SMC parser? they are different formats. If it's based on KawMAN's, I'm guessing SMC?
__________________
asherkin is offline
Nikkii
Member
Join Date: Feb 2012
Old 11-08-2012 , 20:06   Re: PHP SMC/VDF Parser
Reply With Quote #3

Edit:
Looks like it's both, Valve's KeyValues format is VERY close to the SMC format I think?

Comparing admins.cfg/etc to https://developer.valvesoftware.com/wiki/KeyValues, it looks like there aren't any differences at all except that it supports/* and */, which this parser does, and it also supports normal // comments
__________________
Owner of ProbablyAServer, a server without game changing mods and donation benefits

RCON Helper | [TF2] LogUpload | CCC Donator Tags | PHP Steam API Wrapper

Last edited by Nikkii; 11-19-2012 at 19:44.
Nikkii 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 22:52.


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