Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members

RageUtil.h File Reference

#include <unistd.h>

Go to the source code of this file.

Classes

class  RandomGen
class  Regex
struct  char_traits_char_nocase

Defines

#define SAFE_DELETE(p)   { delete (p); (p)=NULL; }
#define SAFE_DELETE_ARRAY(p)   { delete[] (p); (p)=NULL; }
#define ZERO(x)   memset(&x, 0, sizeof(x))
#define COPY(a, b)   { ASSERT(sizeof(a)==sizeof(b)); memcpy(&(a), &(b), sizeof(a)); }
#define ARRAYSIZE(a)   (sizeof(a) / sizeof((a)[0]))
#define MAX(a, b)   (((a) > (b)) ? (a) : (b))
#define MIN(a, b)   (((a) < (b)) ? (a) : (b))
#define clamp(val, low, high)   ( max( (low), min((val),(high)) ) )
#define SCALE(x, l1, h1, l2, h2)   (((x) - (l1)) * ((h2) - (l2)) / ((h1) - (l1)) + (l2))

Typedefs

typedef int longchar
typedef basic_string< char,
char_traits_char_nocase
istring

Functions

float min (float a, int b)
float min (int a, float b)
float max (float a, int b)
float max (int a, float b)
unsigned long min (unsigned int a, unsigned long b)
unsigned long min (unsigned long a, unsigned int b)
unsigned long max (unsigned int a, unsigned long b)
unsigned long max (unsigned long a, unsigned int b)
bool CLAMP (int &x, int l, int h)
bool CLAMP (float &x, float l, float h)
void wrap (int &x, int n)
void wrap (float &x, float n)
uint32_t Swap32 (uint32_t n)
uint32_t Swap24 (uint32_t n)
uint16_t Swap16 (uint16_t n)
uint32_t Swap32BE (uint32_t n)
uint32_t Swap24BE (uint32_t n)
uint16_t Swap16BE (uint16_t n)
uint32_t Swap32LE (uint32_t n)
uint32_t Swap24LE (uint32_t n)
uint16_t Swap16LE (uint16_t n)
float RandomFloat (int &seed)
float RandomFloat ()
float RandomFloat (float fLow, float fHigh)
int RandomInt (int nLow, int nHigh)
float randomf (const float low=-1.0f, const float high=1.0f)
float Quantize (const float f, const float fRoundInterval)
int Quantize (const int i, const int iRoundInterval)
float ftruncf (const float f, const float fTruncInterval)
int QuantizeUp (int i, int iInterval)
void fapproach (float &val, float other_val, float to_move)
float fmodfp (float x, float y)
int power_of_two (int input)
bool IsAnInt (const CString &s)
bool IsHexVal (const CString &s)
float HHMMSSToSeconds (const CString &sHMS)
CString SecondsToHHMMSS (float fSecs)
CString SecondsToMMSSMsMs (float fSecs)
CString SecondsToMMSSMsMsMs (float fSecs)
CString PrettyPercent (float fNumerator, float fDenominator)
CString PrettyPercent (int fNumerator, int fDenominator)
CString Commify (int iNum)
tm GetLocalTime ()
CString ssprintf (const char *fmt,...) PRINTF(1
CString vssprintf (const char *fmt, va_list argList)
void splitpath (const CString &Path, CString &Dir, CString &Filename, CString &Ext)
CString SetExtension (const CString &path, const CString &ext)
CString GetExtension (const CString &sPath)
int utf8_get_char_len (char p)
bool utf8_to_wchar (const CString &s, unsigned &start, wchar_t &ch)
bool utf8_to_wchar_ec (const CString &s, unsigned &start, wchar_t &ch)
void wchar_to_utf8 (wchar_t ch, CString &out)
wchar_t utf8_get_char (const CString &s)
bool utf8_is_valid (const CString &s)
void utf8_remove_bom (CString &s)
CString WStringToCString (const wstring &str)
CString WcharToUTF8 (wchar_t c)
wstring CStringToWstring (const CString &str)
void split (const CString &Source, const CString &Delimitor, CStringArray &AddIt, const bool bIgnoreEmpty=true)
void split (const wstring &Source, const wstring &Delimitor, vector< wstring > &AddIt, const bool bIgnoreEmpty=true)
void split (const CString &Source, const CString &Delimitor, int &begin, int &size, const bool bIgnoreEmpty=true)
void split (const wstring &Source, const wstring &Delimitor, int &begin, int &size, const bool bIgnoreEmpty=true)
void split (const CString &Source, const CString &Delimitor, int &begin, int &size, int len, const bool bIgnoreEmpty)
void split (const wstring &Source, const wstring &Delimitor, int &begin, int &size, int len, const bool bIgnoreEmpty)
CString join (const CString &Delimitor, const CStringArray &Source)
CString join (const CString &Delimitor, CStringArray::const_iterator begin, CStringArray::const_iterator end)
CString GetCwd ()
void CRC32 (unsigned int &iCRC, const void *pBuffer, size_t iSize)
unsigned int GetHashForString (const CString &s)
unsigned int GetHashForFile (const CString &sPath)
unsigned int GetHashForDirectory (const CString &sDir)
bool DirectoryIsEmpty (const CString &dir)
bool CompareCStringsAsc (const CString &str1, const CString &str2)
bool CompareCStringsDesc (const CString &str1, const CString &str2)
void SortCStringArray (CStringArray &AddTo, const bool bSortAscending=true)
float calc_mean (const float *start, const float *end)
float calc_stddev (const float *start, const float *end)
template<class T1, class T2> int FindIndex (T1 begin, T1 end, const T2 *p)
template<class T> T Increment (T a)
template<class T> T Decrement (T a)
void TrimLeft (CString &str, const char *s="\r\n\t ")
void TrimRight (CString &str, const char *s="\r\n\t ")
void StripCrnl (CString &s)
CString DerefRedir (const CString &path)
CString GetRedirContents (const CString &path)
void Replace_Unicode_Markers (CString &Text)
CString WcharDisplayText (wchar_t c)
CString Basename (const CString &dir)
CString Dirname (const CString &dir)
CString Capitalize (const CString &s)
void GetDirListing (const CString &sPath, CStringArray &AddTo, bool bOnlyDirs=false, bool bReturnPathToo=false)
bool DoesFileExist (const CString &sPath)
bool IsAFile (const CString &sPath)
bool IsADirectory (const CString &sPath)
unsigned GetFileSizeInBytes (const CString &sFilePath)
void FlushDirCache ()
void FixSlashesInPlace (CString &sPath)
CString FixSlashes (CString sPath)
void CollapsePath (CString &sPath, bool bRemoveLeadingDot=false)
bool FromString (const CString &sValue, int &out)
bool FromString (const CString &sValue, unsigned &out)
bool FromString (const CString &sValue, float &out)
bool FromString (const CString &sValue, bool &out)
CString ToString (int value)
CString ToString (unsigned value)
CString ToString (float value)
CString ToString (bool value)
bool FileRead (RageFile &f, CString &sOut)
bool FileRead (RageFile &f, int &iOut)
bool FileRead (RageFile &f, unsigned &uOut)
bool FileRead (RageFile &f, float &fOut)
void FileWrite (RageFile &f, const CString &sWrite)
void FileWrite (RageFile &f, int iWrite)
void FileWrite (RageFile &f, size_t uWrite)
void FileWrite (RageFile &f, float fWrite)
bool FileCopy (CString sSrcFile, CString sDstFile)

Variables

int randseed
const wchar_t INVALID_CHAR


Define Documentation

#define ARRAYSIZE  )     (sizeof(a) / sizeof((a)[0]))
 

#define clamp val,
low,
high   )     ( max( (low), min((val),(high)) ) )
 

#define COPY a,
 )     { ASSERT(sizeof(a)==sizeof(b)); memcpy(&(a), &(b), sizeof(a)); }
 

#define MAX a,
 )     (((a) > (b)) ? (a) : (b))
 

#define MIN a,
 )     (((a) < (b)) ? (a) : (b))
 

#define SAFE_DELETE  )     { delete (p); (p)=NULL; }
 

#define SAFE_DELETE_ARRAY  )     { delete[] (p); (p)=NULL; }
 

#define SCALE x,
l1,
h1,
l2,
h2   )     (((x) - (l1)) * ((h2) - (l2)) / ((h1) - (l1)) + (l2))
 

#define ZERO  )     memset(&x, 0, sizeof(x))
 


Typedef Documentation

typedef basic_string<char,char_traits_char_nocase> istring
 

typedef int longchar
 


Function Documentation

CString Basename const CString &  dir  ) 
 

float calc_mean const float *  start,
const float *  end
 

float calc_stddev const float *  start,
const float *  end
 

CString Capitalize const CString &  s  ) 
 

bool CLAMP float &  x,
float  l,
float  h
[inline]
 

bool CLAMP int x,
int  l,
int  h
[inline]
 

void CollapsePath CString &  sPath,
bool  bRemoveLeadingDot = false
 

CString Commify int  iNum  ) 
 

bool CompareCStringsAsc const CString &  str1,
const CString &  str2
 

bool CompareCStringsDesc const CString &  str1,
const CString &  str2
 

void CRC32 unsigned int iCRC,
const void *  pBuffer,
size_t  iSize
 

wstring CStringToWstring const CString &  str  ) 
 

template<class T>
T Decrement a  ) 
 

CString DerefRedir const CString &  path  ) 
 

bool DirectoryIsEmpty const CString &  dir  ) 
 

CString Dirname const CString &  dir  ) 
 

bool DoesFileExist const CString &  sPath  ) 
 

void fapproach float &  val,
float  other_val,
float  to_move
 

bool FileCopy CString  sSrcFile,
CString  sDstFile
 

bool FileRead RageFile f,
float &  fOut
 

bool FileRead RageFile f,
unsigned &  uOut
 

bool FileRead RageFile f,
int iOut
 

bool FileRead RageFile f,
CString &  sOut
 

void FileWrite RageFile f,
float  fWrite
 

void FileWrite RageFile f,
size_t  uWrite
 

void FileWrite RageFile f,
int  iWrite
 

void FileWrite RageFile f,
const CString &  sWrite
 

template<class T1, class T2>
int FindIndex T1  begin,
T1  end,
const T2 *  p
 

CString FixSlashes CString  sPath  ) 
 

void FixSlashesInPlace CString &  sPath  ) 
 

void FlushDirCache  ) 
 

float fmodfp float  x,
float  y
 

bool FromString const CString &  sValue,
bool &  out
 

bool FromString const CString &  sValue,
float &  out
 

bool FromString const CString &  sValue,
unsigned &  out
 

bool FromString const CString &  sValue,
int out
 

float ftruncf const float  f,
const float  fTruncInterval
[inline]
 

CString GetCwd  ) 
 

void GetDirListing const CString &  sPath,
CStringArray &  AddTo,
bool  bOnlyDirs = false,
bool  bReturnPathToo = false
 

CString GetExtension const CString &  sPath  ) 
 

unsigned GetFileSizeInBytes const CString &  sFilePath  ) 
 

unsigned int GetHashForDirectory const CString &  sDir  ) 
 

unsigned int GetHashForFile const CString &  sPath  ) 
 

unsigned int GetHashForString const CString &  s  ) 
 

struct tm GetLocalTime  ) 
 

CString GetRedirContents const CString &  path  ) 
 

float HHMMSSToSeconds const CString &  sHMS  ) 
 

template<class T>
T Increment a  ) 
 

bool IsADirectory const CString &  sPath  ) 
 

bool IsAFile const CString &  sPath  ) 
 

bool IsAnInt const CString &  s  ) 
 

bool IsHexVal const CString &  s  ) 
 

CString join const CString &  Delimitor,
CStringArray::const_iterator  begin,
CStringArray::const_iterator  end
 

CString join const CString &  Delimitor,
const CStringArray &  Source
 

unsigned long max unsigned long  a,
unsigned int  b
[inline]
 

unsigned long max unsigned int  a,
unsigned long  b
[inline]
 

float max int  a,
float  b
[inline]
 

float max float  a,
int  b
[inline]
 

unsigned long min unsigned long  a,
unsigned int  b
[inline]
 

unsigned long min unsigned int  a,
unsigned long  b
[inline]
 

float min int  a,
float  b
[inline]
 

float min float  a,
int  b
[inline]
 

int power_of_two int  input  ) 
 

CString PrettyPercent int  fNumerator,
int  fDenominator
[inline]
 

CString PrettyPercent float  fNumerator,
float  fDenominator
 

int Quantize const int  i,
const int  iRoundInterval
[inline]
 

float Quantize const float  f,
const float  fRoundInterval
[inline]
 

int QuantizeUp int  i,
int  iInterval
[inline]
 

float randomf const float  low = -1.0f,
const float  high = 1.0f
[inline]
 

float RandomFloat float  fLow,
float  fHigh
[inline]
 

float RandomFloat  )  [inline]
 

float RandomFloat int seed  ) 
 

int RandomInt int  nLow,
int  nHigh
[inline]
 

void Replace_Unicode_Markers CString &  Text  ) 
 

CString SecondsToHHMMSS float  fSecs  ) 
 

CString SecondsToMMSSMsMs float  fSecs  ) 
 

CString SecondsToMMSSMsMsMs float  fSecs  ) 
 

CString SetExtension const CString &  path,
const CString &  ext
 

void SortCStringArray CStringArray &  AddTo,
const bool  bSortAscending = true
 

void split const wstring &  Source,
const wstring &  Delimitor,
int begin,
int size,
int  len,
const bool  bIgnoreEmpty
 

void split const CString &  Source,
const CString &  Delimitor,
int begin,
int size,
int  len,
const bool  bIgnoreEmpty
 

void split const wstring &  Source,
const wstring &  Delimitor,
int begin,
int size,
const bool  bIgnoreEmpty = true
 

void split const CString &  Source,
const CString &  Delimitor,
int begin,
int size,
const bool  bIgnoreEmpty = true
 

void split const wstring &  Source,
const wstring &  Delimitor,
vector< wstring > &  AddIt,
const bool  bIgnoreEmpty = true
 

void split const CString &  Source,
const CString &  Delimitor,
CStringArray &  AddIt,
const bool  bIgnoreEmpty = true
 

void splitpath const CString &  Path,
CString &  Dir,
CString &  Filename,
CString &  Ext
 

CString ssprintf const char *  fmt,
  ...
 

void StripCrnl CString &  s  ) 
 

uint16_t Swap16 uint16_t  n  )  [inline]
 

uint16_t Swap16BE uint16_t  n  )  [inline]
 

uint16_t Swap16LE uint16_t  n  )  [inline]
 

uint32_t Swap24 uint32_t  n  )  [inline]
 

uint32_t Swap24BE uint32_t  n  )  [inline]
 

uint32_t Swap24LE uint32_t  n  )  [inline]
 

uint32_t Swap32 uint32_t  n  )  [inline]
 

uint32_t Swap32BE uint32_t  n  )  [inline]
 

uint32_t Swap32LE uint32_t  n  )  [inline]
 

CString ToString bool  value  ) 
 

CString ToString float  value  ) 
 

CString ToString unsigned  value  ) 
 

CString ToString int  value  ) 
 

void TrimLeft CString &  str,
const char *  s = "\r\n\t "
 

void TrimRight CString &  str,
const char *  s = "\r\n\t "
 

wchar_t utf8_get_char const CString &  s  ) 
 

int utf8_get_char_len char  p  ) 
 

bool utf8_is_valid const CString &  s  ) 
 

void utf8_remove_bom CString &  s  ) 
 

bool utf8_to_wchar const CString &  s,
unsigned &  start,
wchar_t &  ch
 

bool utf8_to_wchar_ec const CString &  s,
unsigned &  start,
wchar_t &  ch
 

CString vssprintf const char *  fmt,
va_list  argList
 

void wchar_to_utf8 wchar_t  ch,
CString &  out
 

CString WcharDisplayText wchar_t  c  ) 
 

CString WcharToUTF8 wchar_t  c  ) 
 

void wrap float &  x,
float  n
[inline]
 

void wrap int x,
int  n
[inline]
 

CString WStringToCString const wstring &  str  ) 
 


Variable Documentation

const wchar_t INVALID_CHAR
 

int randseed
 


Generated on Thu Jan 27 20:58:01 2005 for StepMania by doxygen 1.3.7