Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

wvtimeutils.h

Go to the documentation of this file.
00001 /* -*- Mode: C++ -*- 00002 * Worldvisions Weaver Software: 00003 * Copyright (C) 1997-2002 Net Integration Technologies, Inc. 00004 * 00005 * Various little time functions... 00006 * 00007 */ 00008 #ifndef __WVTIMEUTILS_H 00009 #define __WVTIMEUTILS_H 00010 00011 00012 #ifdef _WIN32 00013 #include "winsock2.h" 00014 #include <time.h> 00015 #else 00016 #include <sys/time.h> 00017 #endif 00018 00019 typedef struct timeval WvTime; 00020 00021 static const WvTime wvtime_zero = { 00022 0, 0 00023 }; 00024 00025 /** Returns the number of milliseconds between times a and b. */ 00026 time_t msecdiff(const WvTime &a, const WvTime &b); 00027 00028 /** Returns the current time of day. */ 00029 WvTime wvtime(); 00030 00031 /** Adds the specified number of milliseconds to a time value. */ 00032 WvTime msecadd(const WvTime &a, time_t msec); 00033 00034 /** Returns the timeval difference between two timevals. */ 00035 WvTime tvdiff(const WvTime &a, const WvTime &b); 00036 00037 /** Normalizes the time value. */ 00038 inline void normalize(WvTime &tv) 00039 { 00040 tv.tv_sec += tv.tv_usec / 1000000; 00041 tv.tv_usec %= 1000000; 00042 } 00043 00044 /** Compares two time values. */ 00045 inline bool operator< (const WvTime &a, 00046 const struct timeval &b) 00047 { 00048 return a.tv_sec < b.tv_sec || (a.tv_sec == b.tv_sec 00049 && a.tv_usec < b.tv_usec); 00050 } 00051 00052 inline bool operator== (const WvTime &a, 00053 const struct timeval &b) 00054 { 00055 return a.tv_sec == b.tv_sec && a.tv_usec == b.tv_usec; 00056 } 00057 00058 #endif // __WVTIMEUTILS_H

Generated on Tue Oct 5 01:09:21 2004 for WvStreams by doxygen 1.3.7