Quick Links:

bal | bbl | bdl | bsl

Public Types | Public Member Functions

baltzo::ZoneinfoCache Class Reference

#include <baltzo_zoneinfocache.h>

List of all members.

Public Types

typedef bsl::allocator< char > allocator_type

Public Member Functions

 BSLMF_NESTED_TRAIT_DECLARATION (ZoneinfoCache, bslma::UsesBslmaAllocator)
 ZoneinfoCache (Loader *loader, const allocator_type &allocator=allocator_type())
 ~ZoneinfoCache ()
const ZoneinfogetZoneinfo (const char *timeZoneId)
const ZoneinfogetZoneinfo (int *rc, const char *timeZoneId)
const ZoneinfolookupZoneinfo (const char *timeZoneId) const
allocator_type get_allocator () const

Detailed Description

This class provides an efficient mechanism for retrieving information about a given time zone. The first time a client requests information for some time-zone identifier, that information is loaded (using the Loader supplied at construction), returned to the client (via a const pointer value), and cached for future use. Subsequent requests for the same time-zone return the cached information. The returned values are valid for the lifetime of this object.

This class:

For terminology see bsldoc_glossary.

See Component baltzo_zoneinfocache


Member Typedef Documentation


Constructor & Destructor Documentation

baltzo::ZoneinfoCache::ZoneinfoCache ( Loader loader,
const allocator_type allocator = allocator_type() 
) [explicit]

Create an empty cache of time-zone information that will use the specified loader to populate the cache, as-needed, with time zone information. Optionally specify an allocator (e.g., the address of a bslma::Allocator object) to supply memory; otherwise, the default allocator is used. In order the populate the cache for a time zone identifier, loader must return a Zoneinfo object that is well-formed (see ZoneinfoUtil::isWellFormed) and whose identifier matches the supplied time zone identifier.

baltzo::ZoneinfoCache::~ZoneinfoCache (  ) 

Destroy this object.


Member Function Documentation

baltzo::ZoneinfoCache::BSLMF_NESTED_TRAIT_DECLARATION ( ZoneinfoCache  ,
bslma::UsesBslmaAllocator   
)

ZoneinfoCache is allocator-aware.

const Zoneinfo* baltzo::ZoneinfoCache::getZoneinfo ( const char *  timeZoneId  ) 
const Zoneinfo* baltzo::ZoneinfoCache::getZoneinfo ( int *  rc,
const char *  timeZoneId 
)

Return the address of the non-modifiable Zoneinfo object describing the time zone identified by the specified timeZoneId, or 0 if the operation does not succeed. If the information for timeZoneId has not been previously cached, then attempt to populate this object using the loader supplied at construction. Optionally specify the address of an integer, rc, in which to load the return code for this operation. If rc is specified, load 0 into rc if the operation succeeds, ErrorCode::k_UNSUPPORTED_ID if the time-zone identifier is not supported, and a negative value if the operation does not succeed for any other reason. If the returned address is non-zero, the Zoneinfo object returned is guaranteed to be well-formed (i.e., ZoneinfoUtil::isWellFormed will return true if called with the returned value), and remain valid for the lifetime of this object. The behavior is undefined if rc is 0.

const Zoneinfo* baltzo::ZoneinfoCache::lookupZoneinfo ( const char *  timeZoneId  )  const

Return the address of the non-modifiable cached description of the time zone identified by the specified timeZoneId, and 0 if information for timeZoneId has not previously been cached (by a call to getZoneinfo). If the returned address is non-zero, the Zoneinfo object returned is guaranteed to be well-formed (i.e., ZoneinfoUtil::isWellFormed will return 'true if called with the returned value), and remain valid for the lifetime of this object.

allocator_type baltzo::ZoneinfoCache::get_allocator (  )  const

Return the allocator used by this object to supply memory. Note that if no allocator was supplied at construction the default allocator in effect at construction is used.


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