Below is an alternate version I created with a methodmap.
Example done with methodmaps:
Code:
DString handle = DString_Create();
handle.add( "Hello!" );
handle.addex( " The GameTime is %f", GetGameTime() );
char[] buffer = new char[ handle.len() + 1 ];
handle.read( buffer, handle.len() + 1 );
PrintToServer("DString is '%s'", buffer);
delete handle;
Example simplified with new features:
Code:
DString handle = DString_Create( "Hello!" );
handle.addex( " The GameTime is %f", GetGameTime() );
PrintToServer( "DString is '%s'", handle.readex() );
delete handle;
Changelist:
- Added methodmap DString.
- Added dstring initialization.
- Added copy and format functions.
- Added readex function that returns a character array.
- Renamed DString_ADDEXBUFFER to DSTRING_BUFFERLEN.
- Rewritten to not use multiple cell packing. This should reduce plugin weight by doing less native calls. The drawback is that some functions have a max length at DSTRING_BUFFERLEN, which is arbitrarily high at 4048, so you probably will not reach it.
Edit: Attachment outdated, see
post below.