amxmodx/plugins/include/string.inc

101 lines
3.3 KiB
PHP
Raw Normal View History

2004-01-31 23:56:22 +03:00
/* Strings manipulation
2004-03-05 22:30:29 +03:00
*
* by the AMX Mod X Development Team
* originally developed by OLO
*
* This file is provided as is (no warranties).
*/
2004-01-31 23:56:22 +03:00
#if defined _string_included
#endinput
#endif
#define _string_included
2004-01-31 23:56:22 +03:00
/* Checks if source contains string. On success function
* returns position in source, on failure returns -1. */
2004-01-31 23:56:22 +03:00
native contain(const source[],const string[]);
/* Checks if source contains string with case ignoring. On success function
* returns position in source, on failure returns -1. */
2004-01-31 23:56:22 +03:00
native containi(const source[],const string[]);
/* Replaces given string to another in given text. */
native replace(text[],len,const what[],const with[]);
/* Adds one string to another. Last parameter different from 0, specifies
* how many chars we want to add. Function returns number of all merged chars. */
2004-01-31 23:56:22 +03:00
native add(dest[],len,const src[],max=0);
/* Fills string with given format and parameters.
* Function returns number of copied chars.
* Example: format(dest,"Hello %s. You are %d years old","Tom",17). */
2004-09-07 13:26:20 +04:00
native format(output[] ,len ,const format[] , {Float,Sql,Result,_}:...);
2004-01-31 23:56:22 +03:00
/* Gets parameters from function as formated string. */
native format_args(output[] ,len ,pos = 0);
/* Converts number to string. */
2004-03-08 09:07:47 +03:00
native num_to_str(num,string[],len);
2004-03-08 08:29:51 +03:00
2004-01-31 23:56:22 +03:00
/* Returns converted string to number. */
2004-03-08 09:07:47 +03:00
native str_to_num(const string[]);
2004-01-31 23:56:22 +03:00
/* Checks if two strings equal. If len var is set
* then there are only c chars comapred. */
2004-01-31 23:56:22 +03:00
native equal(const a[],const b[],c=0);
/* Checks if two strings equal with case ignoring.
* If len var is set then there are only c chars comapred. */
2004-01-31 23:56:22 +03:00
native equali(const a[],const b[],c=0);
/* Copies one string to another. By len var
* you may specify max. number of chars to copy. */
2004-01-31 23:56:22 +03:00
native copy(dest[],len,const src[]);
/* Copies one string to another until char ch is found.
* By len var you may specify max. number of chars to copy. */
2004-01-31 23:56:22 +03:00
native copyc(dest[],len,const src[],ch);
/* Sets string with given character. */
native setc(src[],len,ch);
/* Gets parameters from text.
* Example: to split text: "^"This is^" the best year",
* call function like this: parse(text,arg1,len1,arg2,len2,arg3,len3,arg4,len4)
* and you will get: "This is", "the", "best", "year"
* Function returns number of parsed parameters. */
2004-01-31 23:56:22 +03:00
native parse(const text[], ... );
2004-04-03 07:00:57 +04:00
/* Gets parameters from text one at a time
It breaks a string into the first parameter and the rest of the parameters
(A left side and right side of the string)
Example: to split text: "^"This is^" the best year",
split(text, arg1, len1, arg2, len2)
2004-04-04 00:05:27 +04:00
arg1="This is", arg2=the best year
This is more useful than parse() because you can keep breaking
2004-04-03 07:00:57 +04:00
any number of arguments */
native strbreak(const text[], Left[], leftLen, Right[], rightLen);
2004-07-24 05:52:45 +04:00
/* Strips spaces from the beginning and end of a string. */
native trim(text[]);
2004-01-31 23:56:22 +03:00
/* Converts all chars in string to lower case. */
native strtolower(string[]);
/* Converts all chars in string to upper case. */
native strtoupper(string[]);
2004-08-01 20:49:24 +04:00
/* Make a string's first character uppercase */
native ucfirst(string[]);
2004-01-31 23:56:22 +03:00
/* Returns true when value is digit. */
native isdigit(ch);
/* Returns true when value is letter. */
native isalpha(ch);
/* Returns true when value is space. */
native isspace(ch);
/* Returns true when value is letter or digit. */
2004-03-05 22:30:29 +03:00
native isalnum(ch);