Aria: ArUtil Class Reference

- Main Page
- Classes
- Files
- Related Pages

- Alphabetical List
- Class List
- Class Hierarchy
- Class Members

# ArUtil Class Reference

`#include <ariaUtil.h>`

List of all members.

## Detailed Description

This class has utility functions.

## 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 Member Functions
static void | addDirectories (char *dest, size_t destLength, const char *baseDir, const char *insideDir)
| Adds two directories, taking care of all slash issues.
static void | appendSlash (std::string &path)
| Appends a slash to the given string path if necessary.
static void | appendSlash (char *path, size_t pathLength)
| Appends a slash to a path if there is not one there already.
static double | atof (const char *nptr)
| Does an atof but if its inf or -inf deals with it fine.
static bool | changeFileTimestamp (const char *fileName, time_t timestamp)
| Sets the timestamp on the specified file.
static const char * | convertBool (int val)
| Converts an integer value into a string for true or false.
static int | creat (const char *pathname, mode_t mode, bool closeOnExec=true)
| Opens a file, defaulting it so that the file will close on exec.
template<class T>
static void | deleteSet (T begin, T end)
| Delete all members of a set. Does NOT empty the set.
template<class T>
static void | deleteSetPairs (T begin, T end)
| Delete all members of a set. Does NOT empty the set.
static void | escapeSpaces (char *dest, const char *src, size_t maxLen)
| Puts a \ before spaces in src, puts it into dest.
static bool | findFile (const char *fileName)
| OS-independent way of checking to see if a file exists and is readable.
static bool | findFirstStringInRegistry (const char *key, const char *value, char *str, int len)
| Returns a string from the Windows registry, searching each of the following registry root paths in order: REGKEY_CURRENT_USER, REGKEY_LOCAL_MACHINE.
static double | findMax (double first, double second)
| Returns the maximum of the two values.
static int | findMax (int first, int second)
| Returns the maximum of the two values.
static double | findMin (double first, double second)
| Returns the minimum of the two values.
static int | findMin (int first, int second)
| Returns the minimum of the two values.
static void | fixSlashes (std::string &path)
| Fixes the slash orientation in the given file path string for the current platform.
static void | fixSlashes (char *path, size_t pathLength)
| Fix the slash orientation in file path string for windows or linux.
static void | fixSlashesBackward (char *path, size_t pathLength)
| Fix the slash orientation in file path string to be all backward.
static void | fixSlashesForward (char *path, size_t pathLength)
| Fix the slash orientation in file path string to be all forward.
static bool | floatIsNormal (double f)
static FILE * | fopen (const char *path, const char *mode, bool closeOnExec=true)
| Opens a file, defaulting it so that the file will close on exec.
static void | functorPrintf (ArFunctor1< const char * > *functor, char *str,...)
| Function for doing a printf style call to a functor.
static bool | getDirectory (const char *fileName, char *result, size_t resultLen)
| Pulls the directory out of a file name.
static bool | getFileName (const char *fileName, char *result, size_t resultLen)
| Pulls the filename out of the file name.
static bool | getStringFromFile (const char *fileName, char *str, size_t strLen)
| Gets a string contained in an arbitrary file.
static bool | getStringFromRegistry (REGKEY root, const char *key, const char *value, char *str, int len)
| Returns a string from the Windows registry.
static unsigned int | getTime (void)
| Get the time in milliseconds.
static bool | isOnlyAlphaNumeric (const char *str)
| Returns true if this string is only alphanumeric, false otherwise.
static bool | isStrEmpty (const char *str)
| Returns true if the given string is null or of zero length, false otherwise.
static bool | localtime (struct tm *result)
static bool | localtime (const time_t *timep, struct tm *result)
static void | lower (char *dest, const char *src, size_t maxLen)
| Lowers a string from src into dest, make sure there's enough space.
static bool | matchCase (const char *baseDir, const char *fileName, char *result, size_t resultLen)
| this matches the case out of what file we want
static int | open (const char *pathname, int flags, mode_t mode, bool closeOnExec=true)
| Opens a file, defaulting it so that the file will close on exec.
static int | open (const char *pathname, int flags, bool closeOnExec=true)
| Opens a file, defaulting it so that the file will close on exec.
static FILE * | popen (const char *command, const char *type, bool closeOnExec=true)
| Opens a pipe, defaulting it so that the file will close on exec.
static void | putCurrentDayInString (char *s, size_t len)
static void | putCurrentHourInString (char *s, size_t len)
static void | putCurrentMinuteInString (char *s, size_t len)
static void | putCurrentMonthInString (char *s, size_t len)
static void | putCurrentSecondInString (char *s, size_t len)
static void | putCurrentYearInString (char *s, size_t len)
static void | setFileCloseOnExec (FILE *file, bool closeOnExec=true)
| Sets if the file descriptor will be closed on exec or not.
static void | setFileCloseOnExec (int fd, bool closeOnExec=true)
| Sets if the file descriptor will be closed on exec or not.
static long | sizeFile (std::string fileName)
| OS-independent way of finding the size of a file.
static long | sizeFile (const char *fileName)
| OS-independent way of finding the size of a file.
static void | sleep (unsigned int ms)
| Sleep for the given number of milliseconds.
static int | strcasecmp (const char *str, const char *str2)
| Finds out if two strings are equal (ignoring case).
static int | strcasecmp (const char *str, std::string str2)
| Finds out if two strings are equal (ignoring case).
static int | strcasecmp (std::string str, const char *str2)
| Finds out if two strings are equal (ignoring case).
static int | strcasecmp (std::string str, std::string str2)
| Finds out if two strings are equal (ignoring case).
static int | strcasequotecmp (const std::string &str1, const std::string &str2)
| Compares two strings (ignoring case and surrounding quotes).
static int | strcmp (const char *str, const char *str2)
| Finds out if two strings are equal.
static int | strcmp (const char *str, std::string str2)
| Finds out if two strings are equal.
static int | strcmp (std::string str, const char *str2)
| Finds out if two strings are equal.
static int | strcmp (std::string str, std::string str2)
| Finds out if two strings are equal.
static bool | stripQuotes (char *dest, const char *src, size_t destLen)
| Strips out the quotes in the src buffer into the dest buffer.
static void | writeToFile (const char *str, FILE *file)
| Function for doing a fprintf to a file (here to make a functor for).
## Static Public Attributes
static const char * | COM1
| First serial port device name (value depends on compilation platform).
static const char * | COM10
| Tenth serial port device name (value depends on compilation platform).
static const char * | COM11
| Eleventh serial port device name (value depends on compilation platform).
static const char * | COM12
| Twelth serial port device name (value depends on compilation platform).
static const char * | COM13
| Thirteenth serial port device name (value depends on compilation platform).
static const char * | COM14
| Fourteenth serial port device name (value depends on compilation platform).
static const char * | COM15
| Fifteenth serial port device name (value depends on compilation platform).
static const char * | COM16
| Sixteenth serial port device name (value depends on compilation platform).
static const char * | COM2
| Second serial port device name (value depends on compilation platform).
static const char * | COM3
| Third serial port device name (value depends on compilation platform).
static const char * | COM4
| Fourth serial port device name (value depends on compilation platform).
static const char * | COM5
| Fifth serial port device name (value depends on compilation platform).
static const char * | COM6
| Sixth serial port device name (value depends on compilation platform).
static const char * | COM7
| Seventh serial port device name (value depends on compilation platform).
static const char * | COM8
| Eighth serial port device name (value depends on compilation platform).
static const char * | COM9
| Ninth serial port device name (value depends on compilation platform).
static const char * | FALSESTRING
| "false"
static const char * | TRUESTRING
| "true"
## Static Protected Member Functions
static std::list< std::string > | splitFileName (const char *fileName)
| this splits up a file name (it isn't exported since it'd crash with dlls)

## Member Enumeration Documentation

enum ArUtil::BITS

Values for the bits from 0 to 16.

Enumerator:

  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

Enumerator:

  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

template<class T>

static void ArUtil::deleteSet | ( | T | begin,
|  | T | 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>

static void ArUtil::deleteSetPairs | ( | T | begin,
|  | T | 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.

static bool ArUtil::floatIsNormal | ( | double | f | ) | `[static]`

Return true if the value of f is not NaN and is not infinite (+/- INF)

static void ArUtil::functorPrintf | ( | ArFunctor1< const char * > * | functor,
|  | char * | str,
|  |  | ... |
| ) |  |  | `[static]`

Function for doing a printf style call to a functor.

Java and Python Wrappers: Not available in Java or Python wrapper libraries.

static bool ArUtil::localtime | ( | struct tm * | result | ) | `[static]`

Call ArUtil::localtime(const time_t*, struct tm *) with the current time obtained by calling time(NULL).

Returns:
  false on error (e.g. invalid input), otherwise true.

static bool ArUtil::localtime | ( | const time_t * | timep,
|  | struct tm * | result |
| ) |  |  | `[static]`

Interface to native platform localtime() function. On Linux, this is equivalent to a call to localtime_r(timep, result) (which is threadsafe, including the returned pointer, since it uses a different time struct for each thread) On Windows, this is equivalent to a call to localtime(timep, result). In addition, a static mutex is used to make it threadsafe.

Parameters:

  | timep | Pointer to current time (Unix time_t; seconds since epoch)
  | result | The result of calling platform localtime function is copied into this struct, so it must have been allocated.

Returns:
  false on error (e.g. invalid input), otherwise true.

Example:

      struct tm t;
      ArUtil::localtime(time(NULL), &t);
      ArLog::log("Current month is %d.\n", t.tm_mon);

static void ArUtil::putCurrentDayInString | ( | char * | s,
|  | size_t | len |
| ) |  |  | `[static]`

Put the current day (GMT) of the month in s (e.g. "20").

Parameters:

  | s | String buffer (allocated) to write day into
  | len | Size of s

static void ArUtil::putCurrentHourInString | ( | char * | s,
|  | size_t | len |
| ) |  |  | `[static]`

Put the current hour (GMT) in s (e.g. "13" for 1 o'clock PM).

Parameters:

  | s | String buffer (allocated) to write hour into
  | len | Size of s

static void ArUtil::putCurrentMinuteInString | ( | char * | s,
|  | size_t | len |
| ) |  |  | `[static]`

Put the current minute (GMT) in s (e.g. "05").

Parameters:

  | s | String buffer (allocated) to write minutes into
  | len | Size of s

static void ArUtil::putCurrentMonthInString | ( | char * | s,
|  | size_t | len |
| ) |  |  | `[static]`

Put the current month (GMT) in s (e.g. "09" if September).

Parameters:

  | s | String buffer (allocated) to write month into
  | len | Size of s

static void ArUtil::putCurrentSecondInString | ( | char * | s,
|  | size_t | len |
| ) |  |  | `[static]`

Put the current second (GMT) in s (e.g. "59").

Parameters:

  | s | String buffer (allocated) to write seconds into
  | len | Size of s

static void ArUtil::putCurrentYearInString | ( | char * | s,
|  | size_t | len |
| ) |  |  | `[static]`

Put the current year (GMT) in s (e.g. "2005").

Parameters:

  | s | String buffer (allocated) to write year into
  | len | Size of s

static int ArUtil::strcasequotecmp | ( | const std::string & | str1,
|  | const std::string & | str2 |
| ) |  |  | `[static]`

Compares two strings (ignoring case and surrounding quotes).

This helper method is primarily used to ignore surrounding quotes when comparing ArArgumentBuilder args.

Returns:
  int set to 0 if the two strings are equivalent, a negative number if str1 is "less than" str2, and a postive number if it is "greater than".

The documentation for this class was generated from the following file:

- ariaUtil.h