interreality.org [VOS]
[Home] [About]
[Screenshots]
[Download]
[News]
[Community]
[Documentation] [Manual]
[Bugs & Requests] [Wiki]

VUtil Namespace Reference

Classes

Enumerations

Functions


Enumeration Type Documentation

Symbolic level names for use with the LOG macro.

The log level threshold is typically set at LOG_NOTIFY, or LOG_DETAIL if compiled in debugging mode.

Enumerator:
LOG_ERROR  Critical, possibly fatal errors.
LOG_WARN  Important warnings.
LOG_NOTIFY  Important information about program state or progress.
LOG_DETAIL  Details about program state or progress, which may be useful for users.
LOG_DEBUG  Verbose program debugging, useful for developers, and details about VOS state or progress.
LOG_VOS_DEBUG  Very verbose program debugging, and VOS debugging info.
LOG_VOS_MSGDATA  Contents of VOS messages.

Definition at line 130 of file log.hh.


Function Documentation

template<>
void VUtil::iteratorReleaseItem ( A3DL::Material **  v  )  [inline]

Definition at line 186 of file material.hh.

template<>
void VUtil::iteratorReleaseItem ( A3DL::Portal **  v  )  [inline]

Definition at line 78 of file portal.hh.

template<>
void VUtil::iteratorReleaseItem ( A3DL::Texture **  v  )  [inline]

Definition at line 138 of file texture.hh.

template<>
void VUtil::iteratorReleaseItem ( VOS::AccessControlList **  v  )  [inline]

Definition at line 82 of file acl.hh.

template<>
void VUtil::iteratorReleaseItem ( VOS::Site **  v  )  [inline]

Definition at line 631 of file site.hh.

template<>
void VUtil::iteratorReleaseItem ( VOS::Vobject **  v  )  [inline]

Definition at line 8 of file vobjectiter.hh.

template<>
void VUtil::iteratorReleaseItem ( VOS::MetaObject **  v  )  [inline]

Definition at line 52 of file vobjectiter.hh.

VUTIL_API void VUtil::gzipUncompress ( unsigned char **  dest,
unsigned int *  destlen,
const unsigned char *  source,
unsigned int  srclen 
)

Uncompress the source gzip data (which may be read directly from a gzip file) into the destination buffer.

Parameters:
dest Used to pass back the uncompressed data. Data is allocated with malloc(), which the user is responsible for free()ing.
destlen Used to pass back the length of the uncompressed data. If this value is zero, decompression failed.
source the compressed data
srclen length of the compressed data

VUTIL_API void VUtil::gzipCompress ( unsigned char **  dest,
unsigned int *  destlen,
const unsigned char *  source,
unsigned int  srclen 
)

Compress the supplied data into gzip format, suitable to be written directly as a gzip file.

Parameters:
dest Used to pass back the compressed data. Data is allocated with malloc(), which the user is responsible for free()ing.
destlen Used to pass back the length of the compressed data. If this value is zero, compression failed.
source the uncompressed data
srclen length of the uncompressed data

VUTIL_API std::string VUtil::detectHostname ( int  fd,
unsigned char  ipaddr[4] 
)

Given a file descriptor of a socket, attempt to determine the most likely "correct" hostname by doing a couple rounds of reverse and forward DNS lookups.

The IP address of that hostname will be returned in ipaddr.

Parameters:
fd file descriptor of an open socket
ipaddr the local IP address
Returns:
our hostname

template<class T>
void VUtil::iteratorReleaseItem ( T *   )  [inline]

Used by the Iterator template to free the elements of the iterator.

Must be specialized for each subclass of Iterator.

Definition at line 41 of file iterator.hh.

VUTIL_API void VUtil::srand_locked ( long   ) 

Seed the random number generator.

Threadsafe.

VUTIL_API long VUtil::rand_locked (  ) 

Returns:
a random number. Threadsafe.

VUTIL_API std::string VUtil::resolve_dir ( const std::string &  path  ) 

VUTIL_API int VUtil::structpack ( uint8_t *  buf,
int  maxsize,
char *  fmt,
  ... 
)

A utility function which writes some variables to the supplied buffer, following the format string.

The values are written in network byte order (big-endian/most significant byte first). The format string supports the following data types:

'c': a char, or single byte

's': a short, or 16 bit integer

'l': a long, or 32 bit integer

'S': a string. This must actually be passed in as two values, first the length (an unsigned integer) and then a char* to the actual character data. The string is packed using a leading 16 bit length followed by the string data.

't': a string. This must actually be passed in as two values, first the length (an unsigned integer) and then a char* to the actual character data. The string is packed using a leading 8 bit length followed by the string data.

'f': a 32-bit IEEE floating point number

Parameters:
buf the buffer to write to
maxsize the maximum size of the buffer, to avoid overflows
fmt the format string
... the values to be written to the buffer
Returns:
the number of bytes written to the buffer, which will always be <= maxsize
Note:
Here's an example of using pack:
uint8_t c = 'Q';
uint16_t s = 42;
uint32_t l = 999999;
char* S = "Foo Bar Baz";
float f = 3.21;
char buffer[256];

int length = structpack(buffer, sizeof(buffer), "cslSf", c, s, l, strlen(S), S, f);

VUTIL_API int VUtil::structpack ( std::string &  str,
unsigned int  offset,
char *  fmt,
  ... 
)

A utility function which writes some variables to the supplied buffer, following the format string.

The values are written in network byte order (big-endian/most significant byte first). The format string supports the following data types:

'c': a char, or single byte

's': a short, or 16 bit integer

'l': a long, or 32 bit integer

'S': a string. This must actually be passed in as two values, first the length (an unsigned integer) and then a char* to the actual character data. The string is packed using a leading 16 bit length followed by the string data.

't': a string. This must actually be passed in as two values, first the length (an unsigned integer) and then a char* to the actual character data. The string is packed using a leading 8 bit length followed by the string data.

'f': a 32-bit IEEE floating point number

Parameters:
buf the buffer to write to
maxsize the maximum size of the buffer, to avoid overflows
fmt the format string
... the values to be written to the buffer
Returns:
the number of bytes written to the buffer, which will always be <= maxsize
Note:
Here's an example of using pack:
uint8_t c = 'Q';
uint16_t s = 42;
uint32_t l = 999999;
char* S = "Foo Bar Baz";
float f = 3.21;
char buffer[256];

int length = structpack(buffer, sizeof(buffer), "cslSf", c, s, l, strlen(S), S, f);
(uint8_t *buf, int maxsize, char *fmt, .

..)

VUTIL_API int VUtil::structunpack ( const uint8_t *  buf,
int  maxsize,
char *  fmt,
  ... 
)

A utility function that reads some values from a packed data buffer.

It is symmetric to the unpack() function. The only major difference being that pointers to variables are passed in to which the unpacked values will be assigned.

The string returned by 'S' or 't' will be malloc()'d and null-terminated (this is no guarantee that it does not contain embedded nulls, however, which is why the string size is returned explicitly) and it is the responsibility of the caller to free it.

Parameters:
buf the buffer to read from
maxsize the maximum size of the buffer, to avoid overruns
fmt the format string
... pointers to variables to store the unpacked contents
Returns:
the number of bytes read
Note:
Here's an example of using unpack:
char* buffer = getSomeData();
int buffersize = getSomeDataLength();

uint8_t c;
uint16_t s;
uint32_t strsize;
uint32_t l;
char* S;
float f;

int length = structunpack(buffer, buffersize, "cslSf", &c, &s, &l, &strsize, &S, &f);

VUTIL_API double VUtil::getRealTime (  ) 

Get the current time in seconds from the underlying operating system call.

VUTIL_API double VUtil::getTimer (  ) 

Get a timer time in seconds.

This is based on the "real" time, but it is guaranteed to always increase between calls. This is necessary to smooth over some odd behavior in certain operating system / hardware combinations where the clock can actually run backwards over short, subsecond periods of time!