Main Page   Class Hierarchy   Compound List   Compound Members  

ArUtil Class Reference

This class has utility functions. More...

#include <ariaUtil.h>

List of all members.

Public Types

enum  BITS {
  BIT0 = 0x1, BIT1 = 0x2, BIT2 = 0x4, BIT3 = 0x8,
  BIT4 = 0x10, BIT5 = 0x20, BIT6 = 0x40, BIT7 = 0x80,
  BIT8 = 0x100, BIT9 = 0x200, BIT10 = 0x400, BIT11 = 0x800,
  BIT12 = 0x1000, BIT13 = 0x2000, BIT14 = 0x4000, BIT15 = 0x8000
}
 Values for the bits from 0 to 16. More...

enum  REGKEY {
  REGKEY_CLASSES_ROOT, REGKEY_CURRENT_CONFIG, REGKEY_CURRENT_USER, REGKEY_LOCAL_MACHINE,
  REGKEY_USERS
}

Static Public Methods

void sleep (unsigned int ms)
 Sleep for the given number of milliseconds. More...

unsigned int getTime (void)
 Get the time in milliseconds. More...

template<class T> void deleteSet (T begin, T end)
 Delete all members of a set. Does NOT empty the set. More...

template<class T> void deleteSetPairs (T begin, T end)
 Delete all members of a set. Does NOT empty the set. More...

void splitString (std::string inString, std::list< std::string > &outList)
 Split a string into a set of words. More...

long sizeFile (std::string fileName)
 OS-independent way of finding the size of a file. More...

bool findFile (const char *fileName)
 OS-independent way of checking to see if a file exists and is readable. More...

bool stripDir (std::string fileIn, std::string &fileOut)
 OS-independent way of stripping the directory from the filename. More...

bool stripFile (std::string fileIn, std::string &fileOut)
 OS-independent way of stripping the filename from the directory. More...

void appendSlash (std::string &path)
 Appends a slash to a path if there is not one there already. More...

void fixSlashes (std::string &path)
 Fix the slash orientation in file path string for windows or linux. More...

void fixSlashesForward (std::string &path)
 Fix the slash orientation in file path string to be all forward. More...

void fixSlashesBackward (std::string &path)
 Fix the slash orientation in file path string to be all backward. More...

int strcmp (std::string str, std::string str2)
 Finds out if two strings are equal. More...

int strcmp (std::string str, const char *str2)
 Finds out if two strings are equal. More...

int strcmp (const char *str, std::string str2)
 Finds out if two strings are equal. More...

int strcmp (const char *str, const char *str2)
 Finds out if two strings are equal. More...

void escapeSpaces (char *dest, const char *src)
 Puts a \ before spaces in src, puts it into dest. More...

std::string getStringFromFile (const char *fileName)
 Returns a string contained in an arbitrary file. More...

bool getStringFromRegistry (REGKEY root, const char *key, const char *value, char *str, int len)
 Returns a string from the Windows registry. More...


Detailed Description

This class has utility functions.


Member Enumeration Documentation

enum ArUtil::BITS
 

Values for the bits from 0 to 16.

Enumeration values:
BIT0  value of BIT0.
BIT1  value of BIT1.
BIT2  value of BIT2.
BIT3  value of BIT3.
BIT4  value of BIT4.
BIT5  value of BIT5.
BIT6  value of BIT6.
BIT7  value of BIT7.
BIT8  value of BIT8.
BIT9  value of BIT9.
BIT10  value of BIT10.
BIT11  value of BIT11.
BIT12  value of BIT12.
BIT13  value of BIT13.
BIT14  value of BIT14.
BIT15  value of BIT15.

enum ArUtil::REGKEY
 

These are for passing into getStringFromRegistry

Enumeration values:
REGKEY_CLASSES_ROOT  use HKEY_CLASSES_ROOT.
REGKEY_CURRENT_CONFIG  use HKEY_CURRENT_CONFIG.
REGKEY_CURRENT_USER  use HKEY_CURRENT_USER.
REGKEY_LOCAL_MACHINE  use HKEY_LOCAL_MACHIE.
REGKEY_USERS  use HKEY_USERS.


Member Function Documentation

void ArUtil::appendSlash std::string &    path [static]
 

Appends a slash to a path if there is not one there already.

Parameters:
path  the path to append a slash to

template<class T>
void ArUtil::deleteSet   begin,
  end
[inline, static]
 

Delete all members of a set. Does NOT empty the set.

Assumes that T is an iterator that supports the operator *, operator!= and operator++. The return is assumed to be a pointer to a class that needs to be deleted.

template<class T>
void ArUtil::deleteSetPairs   begin,
  end
[inline, static]
 

Delete all members of a set. Does NOT empty the set.

Assumes that T is an iterator that supports the operator **, operator!= and operator++. The return is assumed to be a pair. The second value of the pair is assumed to be a pointer to a class that needs to be deleted.

void ArUtil::escapeSpaces char *    dest,
const char *    src
[static]
 

Puts a \ before spaces in src, puts it into dest.

This copies src into dest but puts a \ before any spaces in src, escaping them... its mostly for use with ArArgumentBuilder... make sure you have enough space in the arrays that you're passing as dest... this allocates no memory

bool ArUtil::findFile const char *    fileName [static]
 

OS-independent way of checking to see if a file exists and is readable.

Returns:
true if file is found
Parameters:
fileName  name of the file to size

void ArUtil::fixSlashes std::string &    path [static]
 

Fix the slash orientation in file path string for windows or linux.

Parameters:
path  the path in which to fix the orientation of the slashes

void ArUtil::fixSlashesBackward std::string &    path [static]
 

Fix the slash orientation in file path string to be all backward.

Parameters:
path  the path in which to fix the orientation of the slashes

void ArUtil::fixSlashesForward std::string &    path [static]
 

Fix the slash orientation in file path string to be all forward.

Parameters:
path  the path in which to fix the orientation of the slashes

std::string ArUtil::getStringFromFile const char *    fileName [static]
 

Returns a string contained in an arbitrary file.

This function looks in the given filename and extracts a string from the file. The string can contain spaces or tabs, but a '\r' or '
' will be treated as the end of the string, and the string cannot have more than 1024 characters. This is mostly for use with Linux to pick up the Aria directory from a file in /etc, but will work with Linux or Windows.

Parameters:
filename  the filename to look in
Returns:
the string that was in the file, or a string with length 0 if the file was not found or if the file was empty

bool ArUtil::getStringFromRegistry REGKEY    root,
const char *    key,
const char *    value,
char *    str,
int    len
[static]
 

Returns a string from the Windows registry.

This takes a root key, and looks up the given <key> within that root, then finds the string given to <value> and returns it.

Parameters:
root  the root key to use, one of the REGKEY enums
key  the name of the key to find
value  the value to find the string contained in
str  where to put the string sought, or if it could not be found for some reason an empty (length() == 0) string
len  the length of the allocated memory in str
Returns:
true if the string was found, false if it was not found or if there was a problem such as the string not being long enough

unsigned int ArUtil::getTime void    [static]
 

Get the time in milliseconds.

Get the time in milliseconds, counting from some arbitrary point. This time is only valid within this run of the program.

Returns:
millisecond time

long ArUtil::sizeFile std::string    fileName [static]
 

OS-independent way of finding the size of a file.

Returns:
size in bytes. -1 on error.
Parameters:
fileName  name of the file to size

void ArUtil::sleep unsigned int    ms [static]
 

Sleep for the given number of milliseconds.

This sleeps for the given number of milliseconds... Note in linux it tries to sleep for 10 ms less than the amount given, which should wind up close to correct... Linux is broken in this regard and sleeps for too long... it sleeps for the ceiling of the current 10 ms range, then for an additional 10 ms... so: 11 to 20 ms sleeps for 30 ms... 21 to 30 ms sleeps for 40 ms... 31 to 40 ms sleeps for 50 ms... this continues on up to the values we care about of.. 81 to 90 ms sleeps for 100 ms... 91 to 100 ms sleeps for 110 ms... so we'll sleep for 10 ms less than we want to, which should put us about right... guh

Parameters:
ms  the number of milliseconds to sleep for

void ArUtil::splitString std::string    inString,
std::list< std::string > &    outList
[static]
 

Split a string into a set of words.

Takes a string and splits it into a list of words. It appends the words to the outList. If there is nothing found, it will not touch the outList.

Parameters:
inString  the input string to split
ourList  the list in which to store the words that are found

int ArUtil::strcmp const char *    str,
const char *    str2
[static]
 

Finds out if two strings are equal.

This compares two strings, it returns an integer less than, equal to, or greater than zero if str is found, respectively, to be less than, to match, or be greater than str2.

Parameters:
str  the string to compare
str2  the second string to compare
Returns:
an integer less than, equal to, or greater than zero if str is found, respectively, to be less than, to match, or be greater than str2.

int ArUtil::strcmp const char *    str,
std::string    str2
[static]
 

Finds out if two strings are equal.

This compares two strings, it returns an integer less than, equal to, or greater than zero if str is found, respectively, to be less than, to match, or be greater than str2.

Parameters:
str  the string to compare
str2  the second string to compare
Returns:
an integer less than, equal to, or greater than zero if str is found, respectively, to be less than, to match, or be greater than str2.

int ArUtil::strcmp std::string    str,
const char *    str2
[static]
 

Finds out if two strings are equal.

This compares two strings, it returns an integer less than, equal to, or greater than zero if str is found, respectively, to be less than, to match, or be greater than str2.

Parameters:
str  the string to compare
str2  the second string to compare
Returns:
an integer less than, equal to, or greater than zero if str is found, respectively, to be less than, to match, or be greater than str2.

int ArUtil::strcmp std::string    str,
std::string    str2
[static]
 

Finds out if two strings are equal.

This compares two strings, it returns an integer less than, equal to, or greater than zero if str is found, respectively, to be less than, to match, or be greater than str2.

Parameters:
str  the string to compare
str2  the second string to compare
Returns:
an integer less than, equal to, or greater than zero if str is found, respectively, to be less than, to match, or be greater than str2.

bool ArUtil::stripDir std::string    fileIn,
std::string &    fileOut
[static]
 

OS-independent way of stripping the directory from the filename.

Works for \ and /. Returns true if something was actualy done. Sets fileOut to be what ever the answer is.

Returns:
true if the path contains a file
Parameters:
fileIn  input path/filename
fileOut  output filename

bool ArUtil::stripFile std::string    fileIn,
std::string &    fileOut
[static]
 

OS-independent way of stripping the filename from the directory.

Works for \ and /. Returns true if something was actualy done. Sets fileOut to be what ever the answer is.

Returns:
true if the file contains a path
Parameters:
fileIn  input path/filename
fileOut  output path


The documentation for this class was generated from the following files:
Generated on Tue Nov 12 17:44:07 2002 for Aria by doxygen1.2.13.1 written by Dimitri van Heesch, © 1997-2001