View Single Post
Emp`
AMX Mod X Plugin Approver
Join Date: Aug 2005
Location: Decapod 10
Old 06-23-2015 , 20:38   Re: [INC] DString - Dynamic Strings
Reply With Quote #3

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:
  1. Added methodmap DString.
  2. Added dstring initialization.
  3. Added copy and format functions.
  4. Added readex function that returns a character array.
  5. Renamed DString_ADDEXBUFFER to DSTRING_BUFFERLEN.
  6. 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.
Attached Files
File Type: inc dstring.inc (2.6 KB, 184 views)

Last edited by Emp`; 07-31-2016 at 15:08. Reason: Updated link
Emp` is offline
Send a message via AIM to Emp` Send a message via MSN to Emp` Send a message via Yahoo to Emp` Send a message via Skype™ to Emp`