VUtil Namespace Reference
Classes
- class Iterator
- class ListenerTask
- Template class used to define the task of delivering a particular event object to a particular listener object. More...
- Template class used to define the task of delivering a particular event object to a particular listener object. More...
- class ListenerBase
- Template base class for the listener pattern. More...
- Template base class for the listener pattern. More...
- class Log
- The logging class. More...
- The logging class. More...
- class ObjectExciseListener
- Interface by which an application can be notified that an object wants to be excised. More...
- Interface by which an application can be notified that an object wants to be excised. More...
- class RefCounted
- This is a simple base class for reference counting objects. More...
- This is a simple base class for reference counting objects. More...
- class NullPointerError
- class vRef
- This is a "smart pointer" wrapper class around any RefCounted object. More...
- This is a "smart pointer" wrapper class around any RefCounted object. More...
- class SynchronizedQueue
- A threadsafe queue. More...
- A threadsafe queue. More...
- class Task
- Abstract class representing a closure; that is, some code to execute along with the state needed to execute it. More...
- Abstract class representing a closure; that is, some code to execute along with the state needed to execute it. More...
- class TaskHelper
- A helper thread used by the task queue. More...
- A helper thread used by the task queue. More...
- class TaskHelperThread
- Internal class that works around some weirdness with the way boost::thread works. More...
- Internal class that works around some weirdness with the way boost::thread works. More...
- class TaskQueue
- class BadURLError
- class URL
Enumerations
- enum LogLevelSym {
LOG_ERROR = 0, LOG_WARN, LOG_NOTIFY, LOG_DETAIL,
LOG_DEBUG, LOG_VOS_DEBUG, LOG_VOS_MSGDATA
}- Symbolic level names for use with the LOG macro. More...
- Symbolic level names for use with the LOG macro. More...
Functions
- template<> void iteratorReleaseItem (A3DL::Material **v)
- template<> void iteratorReleaseItem (A3DL::Portal **v)
- template<> void iteratorReleaseItem (A3DL::Texture **v)
- template<> void iteratorReleaseItem (VOS::AccessControlList **v)
- template<> void iteratorReleaseItem (VOS::ParentChildRelation **pcr)
- template<> void iteratorReleaseItem (VOS::Site **v)
- template<> void iteratorReleaseItem (VOS::Vobject **v)
- template<> void iteratorReleaseItem (VOS::MetaObject **v)
- VUTIL_API void gzipUncompress (unsigned char **dest, unsigned int *destlen, const unsigned char *source, unsigned int srclen)
- VUTIL_API void gzipCompress (unsigned char **dest, unsigned int *destlen, const unsigned char *source, unsigned int srclen)
- VUTIL_API std::string detectHostname (int fd, unsigned char ipaddr[4])
- template<class T> void iteratorReleaseItem (T *)
- Used by the Iterator template to free the elements of the iterator.
- Used by the Iterator template to free the elements of the iterator.
- VUTIL_API void srand_locked (long)
- VUTIL_API long rand_locked ()
- VUTIL_API std::string resolve_dir (const std::string &path)
- VUTIL_API int structpack (uint8_t *buf, int maxsize, char *fmt,...)
- VUTIL_API int 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);
- A utility function which writes some variables to the supplied buffer, following the format string.
- VUTIL_API int structunpack (const uint8_t *buf, int maxsize, char *fmt,...)
- VUTIL_API double getRealTime ()
- VUTIL_API double getTimer ()
Enumeration Type Documentation
| enum VUtil::LogLevelSym |
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.
Function Documentation
| void VUtil::iteratorReleaseItem | ( | A3DL::Material ** | v | ) | [inline] |
Definition at line 186 of file material.hh.
| void VUtil::iteratorReleaseItem | ( | A3DL::Portal ** | v | ) | [inline] |
| void VUtil::iteratorReleaseItem | ( | A3DL::Texture ** | v | ) | [inline] |
Definition at line 138 of file texture.hh.
| void VUtil::iteratorReleaseItem | ( | VOS::AccessControlList ** | v | ) | [inline] |
| void VUtil::iteratorReleaseItem | ( | VOS::Site ** | v | ) | [inline] |
| void VUtil::iteratorReleaseItem | ( | VOS::Vobject ** | v | ) | [inline] |
Definition at line 8 of file vobjectiter.hh.
| 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
| 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);
..)
| 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!