LLVM API Documentation

llvm::sys::TimeValue Class Reference

Provides an abstraction for a fixed point in time. More...

#include <TimeValue.h>

Collaboration diagram for llvm::sys::TimeValue:

Collaboration graph
[legend]
List of all members.

Constructors

 TimeValue (SecondsType seconds, NanoSecondsType nanos=0)
 Explicit constructor.
 TimeValue (double new_time)
 Double Constructor.
static TimeValue now ()
 Creates a TimeValue with the current time (UTC).

Operators

TimeValueoperator+= (const TimeValue &that)
 Incrementing assignment operator.
TimeValueoperator-= (const TimeValue &that)
 Decrementing assignment operator.
int operator< (const TimeValue &that) const
 True if this < that.
int operator> (const TimeValue &that) const
 True if this > that.
int operator<= (const TimeValue &that) const
 True if this <= that.
int operator>= (const TimeValue &that) const
 True if this >= that.
int operator== (const TimeValue &that) const
 True iff *this == that. True if this == that.
int operator!= (const TimeValue &that) const
 True if this != that.
TimeValue operator+ (const TimeValue &tv1, const TimeValue &tv2)
 Addition operator.
TimeValue operator- (const TimeValue &tv1, const TimeValue &tv2)
 Subtraction operator.

Public Types

Types
enum  TimeConversions {
  NANOSECONDS_PER_SECOND = 1000000000, MICROSECONDS_PER_SECOND = 1000000, MILLISECONDS_PER_SECOND = 1000, NANOSECONDS_PER_MICROSECOND = 1000,
  NANOSECONDS_PER_MILLISECOND = 1000000, NANOSECONDS_PER_POSIX_TICK = 100, NANOSECONDS_PER_WIN32_TICK = 100
}
typedef int64_t SecondsType
 Type used for representing seconds.
typedef int32_t NanoSecondsType
 Type used for representing nanoseconds.

Public Member Functions

Accessors
SecondsType seconds () const
 Retrieve the seconds component.
NanoSecondsType nanoseconds () const
 Retrieve the nanoseconds component.
uint32_t microseconds () const
 Retrieve the fractional part as microseconds;.
uint32_t milliseconds () const
 Retrieve the fractional part as milliseconds;.
uint64_t usec () const
 Convert to a number of microseconds (can overflow).
uint64_t msec () const
 Convert to a number of milliseconds (can overflow).
uint64_t toPosixTime () const
 Convert to unix time (100 nanoseconds since 12:00:00a Jan 1,1970).
uint64_t toEpochTime () const
uint64_t toWin32Time () const
 Convert to windows time (seconds since 12:00:00a Jan 1, 1601).
void getTimespecTime (uint64_t &seconds, uint32_t &nanos) const
 Convert to timespec time (ala POSIX.1b).
std::string toString () const
 Convert time to a string.
Mutators
void seconds (SecondsType sec)
 Set the seconds component.
void nanoseconds (NanoSecondsType nanos)
 Set the nanoseconds component using a number of nanoseconds.
void microseconds (int32_t micros)
 Set the nanoseconds component using a number of microseconds.
void milliseconds (int32_t millis)
 Set the nanoseconds component using a number of milliseconds.
void usec (int64_t microseconds)
 Converts from microsecond format to TimeValue format.
void msec (int64_t milliseconds)
 Converts from millisecond format to TimeValue format.
void fromEpochTime (SecondsType seconds)
 Convert seconds form PosixTime to TimeValue.
void fromWin32Time (uint64_t win32Time)
 Convert seconds form Windows FILETIME to TimeValue.

Static Public Attributes

Constants
static const TimeValue MinTime
 The smallest possible time value.
static const TimeValue MaxTime
 The largest possible time value.
static const TimeValue ZeroTime
 00:00:00 Jan 1, 2000 UTC.
static const TimeValue PosixZeroTime
 00:00:00 Jan 1, 1970 UTC.
static const TimeValue Win32ZeroTime
 00:00:00 Jan 1, 1601 UTC.

Detailed Description

Provides an abstraction for a fixed point in time.

This class is used where a precise fixed point in time is required. The range of TimeValue spans many hundreds of billions of years both past and present. The precision of TimeValue is to the nanosecond. However, the actual precision of its values will be determined by the resolution of the system clock. The TimeValue class is used in conjunction with several other lib/System interfaces to specify the time at which a call should timeout, etc.

Since:
1.4

Definition at line 32 of file TimeValue.h.


Member Typedef Documentation

typedef int64_t llvm::sys::TimeValue::SecondsType

Type used for representing seconds.

Definition at line 69 of file TimeValue.h.

typedef int32_t llvm::sys::TimeValue::NanoSecondsType

Type used for representing nanoseconds.

Definition at line 70 of file TimeValue.h.


Member Enumeration Documentation

enum llvm::sys::TimeValue::TimeConversions

Enumerator:
NANOSECONDS_PER_SECOND  One Billion.
MICROSECONDS_PER_SECOND  One Million.
MILLISECONDS_PER_SECOND  One Thousand.
NANOSECONDS_PER_MICROSECOND  One Thousand.
NANOSECONDS_PER_MILLISECOND  One Million.
NANOSECONDS_PER_POSIX_TICK  Posix tick is 100 Hz (10ms).
NANOSECONDS_PER_WIN32_TICK  Win32 tick is 100 Hz (10ms).

Definition at line 72 of file TimeValue.h.


Constructor & Destructor Documentation

llvm::sys::TimeValue::TimeValue ( SecondsType  seconds,
NanoSecondsType  nanos = 0 
) [inline, explicit]

Explicit constructor.

Caller provides the exact value in seconds and nanoseconds. The nanos argument defaults to zero for convenience.

Definition at line 89 of file TimeValue.h.

llvm::sys::TimeValue::TimeValue ( double  new_time  )  [inline, explicit]

Double Constructor.

Caller provides the exact value as a double in seconds with the fractional part representing nanoseconds.

Definition at line 95 of file TimeValue.h.

References NANOSECONDS_PER_SECOND.


Member Function Documentation

static TimeValue llvm::sys::TimeValue::now (  )  [static]

Creates a TimeValue with the current time (UTC).

This is a static constructor that returns a TimeValue that represents the current time.

Referenced by llvm::ArchiveMember::ArchiveMember(), and llvm::Archive::writeSymbolTable().

TimeValue& llvm::sys::TimeValue::operator+= ( const TimeValue that  )  [inline]

Incrementing assignment operator.

Add that to this.

Returns:
this

Definition at line 116 of file TimeValue.h.

References nanos_, and seconds_.

TimeValue& llvm::sys::TimeValue::operator-= ( const TimeValue that  )  [inline]

Decrementing assignment operator.

Subtract that from this.

Returns:
this

Definition at line 126 of file TimeValue.h.

References nanos_, and seconds_.

int llvm::sys::TimeValue::operator< ( const TimeValue that  )  const [inline]

True if this < that.

Determine if this is less than that.

Returns:
True iff *this < that.

Definition at line 136 of file TimeValue.h.

int llvm::sys::TimeValue::operator> ( const TimeValue that  )  const [inline]

True if this > that.

Determine if this is greather than that.

Returns:
True iff *this > that.

Definition at line 141 of file TimeValue.h.

References nanos_, and seconds_.

int llvm::sys::TimeValue::operator<= ( const TimeValue that  )  const [inline]

True if this <= that.

Determine if this is less than or equal to that.

Returns:
True iff *this <= that.

Definition at line 153 of file TimeValue.h.

int llvm::sys::TimeValue::operator>= ( const TimeValue that  )  const [inline]

True if this >= that.

Determine if this is greater than or equal to that.

Returns:
True iff *this >= that.

Definition at line 158 of file TimeValue.h.

References nanos_, and seconds_.

int llvm::sys::TimeValue::operator== ( const TimeValue that  )  const [inline]

True iff *this == that. True if this == that.

Determines if two TimeValue objects represent the same moment in time.

Definition at line 170 of file TimeValue.h.

References nanos_, and seconds_.

int llvm::sys::TimeValue::operator!= ( const TimeValue that  )  const [inline]

True if this != that.

Determines if two TimeValue objects represent times that are not the same.

Returns:
True iff *this != that.

Definition at line 179 of file TimeValue.h.

SecondsType llvm::sys::TimeValue::seconds (  )  const [inline]

Retrieve the seconds component.

Returns only the seconds component of the TimeValue. The nanoseconds portion is ignored. No rounding is performed.

Definition at line 199 of file TimeValue.h.

Referenced by getTimeRecord().

NanoSecondsType llvm::sys::TimeValue::nanoseconds (  )  const [inline]

Retrieve the nanoseconds component.

Returns only the nanoseconds component of the TimeValue. The seconds portion is ignored.

Definition at line 204 of file TimeValue.h.

uint32_t llvm::sys::TimeValue::microseconds (  )  const [inline]

Retrieve the fractional part as microseconds;.

Returns only the fractional portion of the TimeValue rounded down to the nearest microsecond (divide by one thousand).

Definition at line 209 of file TimeValue.h.

References NANOSECONDS_PER_MICROSECOND.

Referenced by getTimeRecord().

uint32_t llvm::sys::TimeValue::milliseconds (  )  const [inline]

Retrieve the fractional part as milliseconds;.

Returns only the fractional portion of the TimeValue rounded down to the nearest millisecond (divide by one million).

Definition at line 216 of file TimeValue.h.

References NANOSECONDS_PER_MILLISECOND.

uint64_t llvm::sys::TimeValue::usec (  )  const [inline]

Convert to a number of microseconds (can overflow).

Returns the TimeValue as a number of microseconds. Note that the value returned can overflow because the range of a uint64_t is smaller than the range of a TimeValue. Nevertheless, this is useful on some operating systems and is therefore provided.

Definition at line 225 of file TimeValue.h.

References MICROSECONDS_PER_SECOND, and NANOSECONDS_PER_MICROSECOND.

uint64_t llvm::sys::TimeValue::msec (  )  const [inline]

Convert to a number of milliseconds (can overflow).

Returns the TimeValue as a number of milliseconds. Note that the value returned can overflow because the range of a uint64_t is smaller than the range of a TimeValue. Nevertheless, this is useful on some operating systems and is therefore provided.

Definition at line 235 of file TimeValue.h.

References MILLISECONDS_PER_SECOND, and NANOSECONDS_PER_MILLISECOND.

uint64_t llvm::sys::TimeValue::toPosixTime (  )  const [inline]

Convert to unix time (100 nanoseconds since 12:00:00a Jan 1,1970).

Converts the TimeValue into the corresponding number of "ticks" for Posix, correcting for the difference in Posix zero time.

Definition at line 243 of file TimeValue.h.

References NANOSECONDS_PER_POSIX_TICK, PosixZeroTime, and seconds_.

uint64_t llvm::sys::TimeValue::toEpochTime (  )  const [inline]

Converts the TimeValue into the corresponding number of seconds since the epoch (00:00:00 Jan 1,1970).

Definition at line 251 of file TimeValue.h.

References PosixZeroTime, and seconds_.

Referenced by llvm::Archive::fillHeader(), and llvm::Archive::writeSymbolTable().

uint64_t llvm::sys::TimeValue::toWin32Time (  )  const [inline]

Convert to windows time (seconds since 12:00:00a Jan 1, 1601).

Converts the TiemValue into the correspodning number of "ticks" for Win32 platforms, correcting for the difference in Win32 zero time.

Definition at line 258 of file TimeValue.h.

References NANOSECONDS_PER_WIN32_TICK, seconds_, and Win32ZeroTime.

void llvm::sys::TimeValue::getTimespecTime ( uint64_t &  seconds,
uint32_t &  nanos 
) const [inline]

Convert to timespec time (ala POSIX.1b).

Provides the seconds and nanoseconds as results in its arguments after correction for the Posix zero time.

Definition at line 267 of file TimeValue.h.

References PosixZeroTime, and seconds_.

std::string llvm::sys::TimeValue::toString (  )  const

Convert time to a string.

Provides conversion of the TimeValue into a readable time & date.

Returns:
std::string containing the readable time value

void llvm::sys::TimeValue::seconds ( SecondsType  sec  )  [inline]

Set the seconds component.

The seconds component of the TimeValue is set to sec without modifying the nanoseconds part. This is useful for whole second arithmetic.

Definition at line 285 of file TimeValue.h.

void llvm::sys::TimeValue::nanoseconds ( NanoSecondsType  nanos  )  [inline]

Set the nanoseconds component using a number of nanoseconds.

The nanoseconds component of the TimeValue is set to nanos without modifying the seconds part. This is useful for basic computations involving just the nanoseconds portion. Note that the TimeValue will be normalized after this call so that the fractional (nanoseconds) portion will have the smallest equivalent value.

Definition at line 296 of file TimeValue.h.

void llvm::sys::TimeValue::microseconds ( int32_t  micros  )  [inline]

Set the nanoseconds component using a number of microseconds.

The seconds component remains unchanged.

Definition at line 303 of file TimeValue.h.

References NANOSECONDS_PER_MICROSECOND.

void llvm::sys::TimeValue::milliseconds ( int32_t  millis  )  [inline]

Set the nanoseconds component using a number of milliseconds.

The seconds component remains unchanged.

Definition at line 310 of file TimeValue.h.

References NANOSECONDS_PER_MILLISECOND.

void llvm::sys::TimeValue::usec ( int64_t  microseconds  )  [inline]

Converts from microsecond format to TimeValue format.

Definition at line 316 of file TimeValue.h.

References MICROSECONDS_PER_SECOND, and NANOSECONDS_PER_MICROSECOND.

void llvm::sys::TimeValue::msec ( int64_t  milliseconds  )  [inline]

Converts from millisecond format to TimeValue format.

Definition at line 324 of file TimeValue.h.

References MILLISECONDS_PER_SECOND, and NANOSECONDS_PER_MILLISECOND.

void llvm::sys::TimeValue::fromEpochTime ( SecondsType  seconds  )  [inline]

Convert seconds form PosixTime to TimeValue.

Converts the seconds argument from PosixTime to the corresponding TimeValue and assigns that value to this.

Definition at line 334 of file TimeValue.h.

References PosixZeroTime, and seconds_.

Referenced by llvm::Archive::parseMemberHeader().

void llvm::sys::TimeValue::fromWin32Time ( uint64_t  win32Time  )  [inline]

Convert seconds form Windows FILETIME to TimeValue.

Converts the win32Time argument from Windows FILETIME to the corresponding TimeValue and assigns that value to this.

Definition at line 343 of file TimeValue.h.

References seconds_, and Win32ZeroTime.


Friends And Related Function Documentation

TimeValue operator+ ( const TimeValue tv1,
const TimeValue tv2 
) [friend]

Addition operator.

Adds two TimeValue objects together.

Returns:
The sum of the two operands as a new TimeValue

Definition at line 369 of file TimeValue.h.

TimeValue operator- ( const TimeValue tv1,
const TimeValue tv2 
) [friend]

Subtraction operator.

Subtracts two TimeValue objects.

Returns:
The difference of the two operands as a new TimeValue

Definition at line 375 of file TimeValue.h.


Member Data Documentation

const TimeValue llvm::TimeValue::MinTime [static]

The smallest possible time value.

A constant TimeValue representing the smallest time value permissable by the class. MinTime is some point in the distant past, about 300 billion years BCE.

Definition at line 42 of file TimeValue.h.

const TimeValue llvm::TimeValue::MaxTime [static]

The largest possible time value.

A constant TimeValue representing the largest time value permissable by the class. MaxTime is some point in the distant future, about 300 billion years AD.

Definition at line 48 of file TimeValue.h.

const TimeValue llvm::TimeValue::ZeroTime [static]

00:00:00 Jan 1, 2000 UTC.

A constant TimeValue representing the base time, or zero time of 00:00:00 (midnight) January 1st, 2000.

Definition at line 53 of file TimeValue.h.

const TimeValue llvm::TimeValue::PosixZeroTime [static]

00:00:00 Jan 1, 1970 UTC.

A constant TimeValue for the Posix base time which is 00:00:00 (midnight) January 1st, 1970.

Definition at line 58 of file TimeValue.h.

Referenced by fromEpochTime(), getTimespecTime(), toEpochTime(), and toPosixTime().

const TimeValue llvm::TimeValue::Win32ZeroTime [static]

00:00:00 Jan 1, 1601 UTC.

A constant TimeValue for the Win32 base time which is 00:00:00 (midnight) January 1st, 1601.

Definition at line 63 of file TimeValue.h.

Referenced by fromWin32Time(), and toWin32Time().


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