Go to the source code of this file.
Functions | |
DECLSPEC const char * | intToStr (int i, int base=10) |
DECLSPEC char * | intToStr (int i, char *buf, int base=10) |
DECLSPEC char * | uintToStr (unsigned int i, char *buf, unsigned int base=10) |
DECLSPEC Uint32 | xStrToUL (const char *str, bool *err=NULL) |
DECLSPEC SDL_Rect | strToRect (const char *str) |
DECLSPEC bool | strToBool (const char *s) |
DECLSPEC Uint32 | strToIP (const char *str) |
DECLSPEC IPaddress | strToIPaddress (const char *str) |
DECLSPEC SDLKey | strToKey (const char *str) |
DECLSPEC SDLMod | strToMod (const char *str) |
DECLSPEC int | byteToStr (Uint8 b, char *buf) |
DECLSPEC const char * | IPToStr (Uint32 ip, char *buf) |
DECLSPEC const char * | IPToStr (const IPaddress &ip, char *buf) |
DECLSPEC SDL_Color | ULToColor (Uint32 v) |
DECLSPEC const char * | getUserDirectory () |
DECLSPEC std::string | makeEnvStr (const char *str) |
DECLSPEC std::string | makeEnvPath (const char *str) |
DECLSPEC bool | patMatch (const char *pattern, const char *string) |
DECLSPEC bool | patiMatch (const char *pattern, const char *string) |
char * | getLocalIP (bool bIPv4=true) |
Required header file:
#include <functions.h>
With including this file you get all important string conversation methods, that are used by the Netrinjo engine. You can convert numbers, boolean expressions, IP-addresses and colors in both ways to a string and from a string.
Furthermore the function getUserDirectory is declared here.
Used Abbreviation:
NBO: Network Byte Order
DECLSPEC int byteToStr | ( | Uint8 | b, | |
char * | buf | |||
) |
Converts a byte to a string.
b | The number to convert | |
buf | Pointer to reserved space, where the number will be stored in form of a string |
char* getLocalIP | ( | bool | bIPv4 = true |
) |
Gets the local IP-address (only for UNIX-based platforms).
bIPv4 | if true, IPv4-addresses are prefered; otherwise IPv6-addresses this does not guarantee, that the result is of that kind. |
DECLSPEC const char* getUserDirectory | ( | ) |
DECLSPEC char* intToStr | ( | int | i, | |
char * | buf, | |||
int | base = 10 | |||
) |
Converts an integer value to a string. This function is thread safe.
i | The number to convert | |
buf | A pointer to reserved space of at least 33 characters | |
base | The base to use, if it's less than 2, 2 will be used; if it's above 36, 36 will be used. |
DECLSPEC const char* intToStr | ( | int | i, | |
int | base = 10 | |||
) |
Converts an integer value to a string.
i | The number to convert | |
base | The base to use, if it's less than 2, 2 will be used; if it's above 36, 36 will be used. |
DECLSPEC const char* IPToStr | ( | const IPaddress & | ip, | |
char * | buf | |||
) |
Converts an IP address (in NBO) with the portnumber to a string in the following format:
<a>.<b>.<c>.<d>:<Port>
ip | The IP address to convert | |
buf | Pointer to reserved space, where the IP address will be stored |
DECLSPEC const char* IPToStr | ( | Uint32 | ip, | |
char * | buf | |||
) |
Converts an IP address (in NBO) without the portnumber to a string in the following format:
<a>.<b>.<c>.<d>
ip | The IP address to convert | |
buf | Pointer to reserved space, where the IP address will be stored |
DECLSPEC std::string makeEnvPath | ( | const char * | str | ) |
Does the same as makeEnvStr(), but replaces a leading "~/" by the user's home directory. E.g: "~/.netrinjo" will become "/home/username/.netrinjo", if the user's home is at "/home/username".
str | the string to parse |
DECLSPEC std::string makeEnvStr | ( | const char * | str | ) |
Replaces the ocurrencies of "$(...)" with the content of the specified environment variable. E.g.: "$(USERNAME)" will be replaced by the user's name.
str | the string to parse |
DECLSPEC bool patiMatch | ( | const char * | pattern, | |
const char * | string | |||
) |
Case-insensitive pattern match
pattern | the pattern | |
string | the string, that is checked to match the pattern |
DECLSPEC bool patMatch | ( | const char * | pattern, | |
const char * | string | |||
) |
Case-sensitive pattern match
pattern | the pattern | |
string | the string, that is checked to match the pattern |
DECLSPEC bool strToBool | ( | const char * | s | ) |
Converts a string to a boolean value.
s | The string to read (case insensitive) |
DECLSPEC Uint32 strToIP | ( | const char * | str | ) |
Converts a string to an IPv4-value (in NBO),
str | can either be a single decimal number or consist of 4 decimal byte-numbers, separated by a '.' (no spaces/tabs allowed) |
DECLSPEC IPaddress strToIPaddress | ( | const char * | str | ) |
Converts a string to an IPv4-address-value (in NBO) like strToIP(..) if there is a ':' in the string, the number behind the ':' is read as the port.
str | The string to convert. |
DECLSPEC SDLKey strToKey | ( | const char * | str | ) |
Converts a string to a SDLKey value.
str | The string to convert. |
DECLSPEC SDLMod strToMod | ( | const char * | str | ) |
Converts a string to a key modifier (may be a combination, separated by '+').
str | The string to convert. |
DECLSPEC SDL_Rect strToRect | ( | const char * | str | ) |
DECLSPEC char* uintToStr | ( | unsigned int | i, | |
char * | buf, | |||
unsigned int | base = 10 | |||
) |
Converts an unsigned integer value to a string. This function is thread safe. See intToStr( int i, char *buf, int base ) for more information.
DECLSPEC SDL_Color ULToColor | ( | Uint32 | v | ) |
Converts an unsigned integer value to a SDL_Color-value.
v | The number to convert: the blue-value is the lowest byte, green is middle-value, red-value is 2nd-highest (bits 16..23), the highest byte is ignored |
DECLSPEC Uint32 xStrToUL | ( | const char * | str, | |
bool * | err = NULL | |||
) |
Converts a string to an unsigned long value, the base is usually 10, but it changes, if the number-string has a special prefix:
prefix => base 0q, q => 4 0, 0o, o => 8 0x, x, #, h, $ => 16 0b, b => 2 0d, d => 10
str | The string to convert. | |
err | is assigned true, if the string could not be converted, otherwise false is assigned; if it is NULL, it is ignored |