Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

/home/groups/n/no/noxwizard/cvs/src/basics.h File Reference

Header for conversion functions. More...

#include "typedefs.h"

Go to the source code of this file.

Bases

bases for conversion from string to number

#define BASE_INARRAY   -1
#define BASE_AUTO   0
#define BASE_BIN   2
#define BASE_OCT   8
#define BASE_DEC   10
#define BASE_HEX   16

Wrappers for stdlib num-2-str functions

Author:
Lord Binary


void numtostr (UI32 i, char *ourstring)
 convert the integer into a string in decimal base

void hextostr (UI32 i, char *ourstring)
 convert the integer into a string in hexadecimal base


Wrappers

Wrappers for c++ strings

Author:
Sparhawk


int str2num (std::string &s, int base=0)
 wrapper to str2num function

int str2num (std::wstring &s, int base=0)
 Wrapper to str2num function.

int hex2num (std::string &s)
 wrapper to str2num function


Functions

SI32 LongFromCharPtr (const unsigned char *p)
 Calculates a long int from 4 subsequent bytes pointed to by p.

SI16 ShortFromCharPtr (const unsigned char *p)
 Calculates a short int from 2 subsequent bytes pointed to by p.

void LongToCharPtr (const UI32 i, unsigned char *p)
 Stores a long int into 4 subsequent bytes pointed to by 'p'.

void ShortToCharPtr (const UI16 i, unsigned char *p)
 Stores a short int into 2 subsequent bytes pointed to by 'p'.

int str2num (char *sz, int base=0)
 Conversion from sz to numbers.

int str2num (wchar_t *sz, int base=0)
 Conversion from sz to numbers.

int hex2num (char *sz)
 New style hexstring to number.

int fillIntArray (char *str, int *array, int maxsize, int defval=-1, int base=0)
 fills an integer array with tokens extracted from a string

void readSplitted (FILE *F, char *script1, char *script2)
 reads a line splitted (read2 clone)

int RandomNum (int nLowNum, int nHighNum)
 Returns a random number between bounds.

char * RealTime (char *time_str)
 return current local time

Location Loc (UI16 x, UI16 y, SI08 z, SI08 dispz=0)
 build a Location structure


Detailed Description

Header for conversion functions.

Note:
documentation ported to doxygen by Akron

Define Documentation

#define BASE_AUTO   0
 

#define BASE_BIN   2
 

#define BASE_DEC   10
 

#define BASE_HEX   16
 

#define BASE_INARRAY   -1
 

#define BASE_OCT   8
 


Function Documentation

int fillIntArray char *    str,
int *    array,
int    maxsize,
int    defval,
int    base
 

fills an integer array with tokens extracted from a string

Author:
Xanathar
Returns:
int the number of number read from the string
Parameters:
str  the string
array  the array
maxsize  the size of array
defval  -1 -> the default value for uninitialized items
base  the base for number conversion

int hex2num std::string &    s [inline]
 

wrapper to str2num function

Author:
Sparhawk
Parameters:
s  the hexstring
Returns:
the number represented by the string

int hex2num char *    sz [inline]
 

New style hexstring to number.

Author:
Xanathar
Parameters:
sz  the hexstring
Returns:
the number represented by the string

void hextostr UI32    i,
char *    ourstring
[inline]
 

convert the integer into a string in hexadecimal base

Parameters:
i  integer to convert
ourstring  string to write the number to

Location Loc UI16    x,
UI16    y,
SI08    z,
SI08    dispz
 

build a Location structure

Author:
Anthalir
Returns:
The Location structure that represent the, ehm, location
Since:
0.82a
Parameters:
x  X-Coordinate
y  Y-Coordinate
z  Z-Coordinate
dispz  displayed z value

SI32 LongFromCharPtr const unsigned char *    p [inline]
 

Calculates a long int from 4 subsequent bytes pointed to by p.

Author:
Duke
Parameters:
p  pointer to the 4 subsequent bytes
Returns:
the value of the long found
Note:
assuming 'normal' (big endian, ndAkron) byte order (NOT intel style)

void LongToCharPtr const UI32    i,
unsigned char *    p
[inline]
 

Stores a long int into 4 subsequent bytes pointed to by 'p'.

Author:
Duke
Parameters:
i  value to store
p  pointer to the char array
Note:
assuming 'normal' (big endian, ndAkron) byte order (NOT intel style)

void numtostr UI32    i,
char *    ourstring
[inline]
 

convert the integer into a string in decimal base

Parameters:
i  integer to convert
ourstring  string to write the number to

int RandomNum int    nLowNum,
int    nHighNum
 

Returns a random number between bounds.

Author:
?
Returns:
int the number
Parameters:
nLowNum  lower bound
nHighNum  higher bound

void readSplitted FILE *    F,
char *    script1,
char *    script2
 

reads a line splitted (read2 clone)

Author:
Xanathar
Parameters:
F  the file to read from
script1  where we'll put the first token of the string
script2  where we'll put the rest of the string

char* RealTime char *    time_str
 

return current local time

Returns:
char* the time (time_str)
Parameters:
time_str  a string with enough memory allocated

SI16 ShortFromCharPtr const unsigned char *    p [inline]
 

Calculates a short int from 2 subsequent bytes pointed to by p.

Author:
Duke
Parameters:
p  pointer to the 2 subsequent bytes
Returns:
the value of the short found
Note:
assuming 'normal' (big endian, ndAkron) byte order (NOT intel style)

void ShortToCharPtr const UI16    i,
unsigned char *    p
[inline]
 

Stores a short int into 2 subsequent bytes pointed to by 'p'.

Author:
Duke
Parameters:
i  value to store
p  pointer to the char array
Note:
assuming 'normal' (big endian, ndAkron) byte order (NOT intel style)

int str2num std::wstring &    s,
int    base = 0
[inline]
 

Wrapper to str2num function.

Author:
Endymion
Parameters:
s  wstring that represent the number
base  base in which the number is (see Bases)
Returns:
the number represented by the string

int str2num std::string &    s,
int    base = 0
[inline]
 

wrapper to str2num function

Author:
Sparhawk
Parameters:
s  string that represent the number
base  base in which the number is (see Bases)
Returns:
the number represented by the string

int str2num wchar_t *    sz,
int    base
 

Conversion from sz to numbers.

Author:
Endymion
Returns:
int the number or 0 if no conversion possible
Parameters:
sz  the string
base  number's base

int str2num char *    sz,
int    base
 

Conversion from sz to numbers.

Author:
Xanathar
Returns:
int the number or 0 if no conversion possible
Parameters:
sz  the string
base  number's base
SourceForge.net Logo