Raised This Month: $ Target: $400
 0% 

Module: StringX [C++ CString Solutions For AmxModX]


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
AntiBots
Veteran Member
Join Date: May 2008
Location: Brazil
Old 04-16-2010 , 20:02   Module: StringX [C++ CString Solutions For AmxModX]
Reply With Quote #1

StringX1.1
By Ramón Berrutti (me)


DESCRIPTION: Well, with this native you can do many thing with String. Example, Return Strings in a Forward. An more think. I try to port the best I can. CString to AmxModx. Yo don't need to be worried about the String Size.

NATIVES:
PHP Code:
/**
 * Create a new StringX Member.
 * An example would be: StringX_Create("Here Are Some Dinamic Private Text");
 *
 * @param text        If you want to set data in Constructor.
 * @param private    Other Plugin's Can to Read & Write the StringX?.
 * @return         Returns a handle of the StringX new Member.
 */
native StringX:StringX_Create( const text[] = "", private = true );

/**
 * Destroy A Specific StringX Member.
 *
 * @param Handle    Pointer of the StringX Member.
 * @return         *Error: STRINGX_ERROR.
            *Success: true.
 */
native StringX_DestroyStringX:Handle );



/**
 * Compare two Specifics StringX Members.
 *
 * @param Handle1    Pointer of the StringX Member.
 * @param Handle1    Pointer of the StringX Member.
 * @return         *Error: STRINGX_ERROR.
            * Handle1 <  Handle2 = -1
            * Handle1 == Handle2 =  0
            * Handle1 >  Hanble2 =  1
 */
native StringX_CompareStringX:Handle1StringX:Handle2 );

/**
 * Compare a Specific StringX Member with a Text.
 *
 * @param Handle1    Pointer of the StringX Member.
 * @param text        Text to be Compared.
 * @return         *Error: STRINGX_ERROR.
            * Handle1 <  Handle2 = -1
            * Handle1 == Handle2 =  0
            * Handle1 >  Hanble2 =  1
 */
native StringX_szCompareStringX:Handle, const text[] = "" );



/**
 * Copy Handle2 to Handle1 ( Handle1 = Handle2 ).
 *
 * @param Handle1    Pointer of the StringX Member.
 * @param Handle2    Pointer of the StringX Member.
 * @return         *Error: STRINGX_ERROR.
            *Success: Size of the StringX.
 */
native StringX_AssignStringX:Handle1StringX:Handle2 );

/**
 * Copy Text to The Specific StringX Member.
 *
 * @param Handle    Pointer of the StringX Member.
 * @param text        Text to Copy.
 * @return         *Error: STRINGX_ERROR.
            *Success: Size of the StringX.
 */
native StringX_szAssignStringX:Handle, const text[] = "" );



/**
 * Add Handle2 to Handle1 ( Handle1 += Handle2 ).
 *
 * @param Handle1    Pointer of the StringX Member.
 * @param Handle2    Pointer of the StringX Member.
 * @return         *Error: STRINGX_ERROR.
            *Success: Size of the StringX.
 */
native StringX_AppendStringX:Handle1StringX:Handle2 );

/**
 * Add Text to The Specific StringX Member.
 *
 * @param Handle    Pointer of the StringX Member.
 * @param text        Text to Add.
 * @return         *Error: STRINGX_ERROR.
            *Success: Size of the StringX.
 */
native StringX_szAppendStringX:Handle, const text[] = "" );



/**
 * String between (start) and (start + npos).
 *
 * @param Handle    Pointer of the StringX Member.
 * @param HandleOut    Pointer of the StringX Member.
 * @param start        Start Position.
 * @param npos        (I Don't know how to Explain).
 * @return         *Error: STRINGX_ERROR.
            *Success: Size of the new StringX.
 */
native StringX_SubStrStringX:HandleStringX:HandleOutstartnpos = -);

/**
 * String between (start) and (start + npos).
 *
 * @param Handle    Pointer of the StringX Member.
 * @param output    Array to Insert Data.
 * @param output_len    Len of the Array to Insert Data.
 * @param start        Start Position.
 * @param npos        (I Don't know how to Explain).
 * @return         *Error: STRINGX_ERROR.
            *Success: Size of the new StringX.
 */
native StringX_szSubStrStringX:Handleoutput[], output_lenindexnpos = -);



/**
 * Clean StringX Member ( StringX = "" ).
 *
 * @param Handle1    Pointer of the StringX Member.
 * @param Handle2    Pointer of the StringX Member.
 * @return         *Error: STRINGX_ERROR.
            *Success: 0.
 */
native StringX_CleanStringX:Handle );

/**
 * Clean StringX Member ( StringX = "" ).
 *
 * @param Handle1    Pointer of the StringX Member.
 * @param Handle2    Pointer of the StringX Member.
 * @return         *Error: STRINGX_ERROR.
            *StringX != "": false.
            *StringX == "": true.
 */
native StringX_IsEmptyStringX:Handle );

/**
 * Size of StringX Member.
 *
 * @param Handle    Pointer of the StringX Member.
 * @return         *Error: STRINGX_ERROR.
            *Success: Size of the StringX.
 */
native StringX_SizeStringX:Handle );

/**
 * Trim Space of StringX Member.
 *
 * @param Handle    Pointer of the StringX Member.
 * @return         *Error: STRINGX_ERROR.
            *Success: Size of the StringX.
 */
native StringX_TrimStringX:Handle );

/**
 * Erase from (start) to (start + npos) of StringX Member.
 *
 * @param Handle    Pointer of the StringX Member.
 * @param start        Start Position.
 * @param npos        (I Don't know how to Explain).
 * @return         *Error: STRINGX_ERROR.
            *Success: Size of the StringX.
 */
native StringX_EraseStringX:Handlestartnpos = -);

/**
 * Convert All Chars to Lower of StringX Member.
 *
 * @param Handle    Pointer of the StringX Member.
 * @return         *Error: STRINGX_ERROR.
            *Success: Size of the StringX.
 */
native StringX_ToLowerStringX:Handle );



/**
 * Change the Access to the StringX Member.
 *
 * @param Handle    Pointer of the StringX Member.
 * @param plugin_id    The Id of the plugin, If set 0, All can Access.
 * @return         *Error: STRINGX_ERROR.
            *Success: Size of the StringX.
 */
native StringX_SetPluginStringX:Handleplugin_id );

/**
 * Export a StringX Member to an Array.
 *
 * @param Handle    Pointer of the StringX Member.
 * @param output    Array to Insert Data.
 * @param output_len    Len of the Array to Insert Data.
 * @return         *Error: STRINGX_ERROR.
            *Success: Size of the StringX.
 */
native StringX_ExportStringX:Handleoutput[], output_len ); 


New Natives:
PHP Code:
native StringX_FindStringX:Handleccharstart 0);

native StringX_GetCharStringX:Handlenpos );
native StringX_SetCharStringX:Handlenposnewchar); 

CREDITS:

Kiske: Test Module if run.
IneedHelp: Do the first test with Natives, Because I can't.
Seta00: Report TypoError: Assing --> Assign And Valid the Handle



PD: I have yo eat know so I don't post a nice describe of the module.

Tested Only on Windows but I compiled in Linux to.
Attached Files
File Type: dll StringX_amxx.dll (70.5 KB, 219 views)
File Type: so StringX_amxx_i386.so (28.5 KB, 214 views)
File Type: zip StringX.zip (94.9 KB, 192 views)
__________________

Last edited by AntiBots; 04-17-2010 at 10:04. Reason: Update to 1.1
AntiBots is offline
Send a message via ICQ to AntiBots Send a message via MSN to AntiBots Send a message via Skype™ to AntiBots
Kiske
Veteran Member
Join Date: May 2009
Old 04-16-2010 , 20:06   Re: Module: StringX [C++ CString Solutions For AmxModX]
Reply With Quote #2

Very very thanks
__________________

Kiske is offline
Send a message via Skype™ to Kiske
Seta00
The Seta00 user has crashed.
Join Date: Jan 2010
Location: Berlin
Old 04-16-2010 , 22:08   Re: Module: StringX [C++ CString Solutions For AmxModX]
Reply With Quote #3

Quote:
Originally Posted by AntiBots View Post
native StringX_Assing
Assign*

EDIT: And why you delete the non-existent strings on `OnAmxxAttach' ?

EDIT2: Also, reinterpret_cast won't return NULL if the pointer isn't valid.
PHP Code:
StringX *tmp reinterpret_cast<StringX *>(param);

        if( 
tmp == NULL )
        {
            
MF_LogError(amxAMX_ERR_NATIVE"Invalid StringX handle provided (%d)"param);
            return 
NULL;
        } 
You have to manually search for the string by ID to check for its validness.

Last edited by Seta00; 04-16-2010 at 22:16.
Seta00 is offline
AntiBots
Veteran Member
Join Date: May 2008
Location: Brazil
Old 04-16-2010 , 22:09   Re: Module: StringX [C++ CString Solutions For AmxModX]
Reply With Quote #4

Quote:
Originally Posted by Seta00 View Post
Assign*
LOL, Another TypoError

Thanks.
__________________
AntiBots is offline
Send a message via ICQ to AntiBots Send a message via MSN to AntiBots Send a message via Skype™ to AntiBots
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 07:39.


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