Quick Links:

bal | bbl | bdl | bsl

Public Types | Public Member Functions

baltzo::TestLoader Class Reference

#include <baltzo_testloader.h>

Inheritance diagram for baltzo::TestLoader:
baltzo::Loader

List of all members.

Public Types

typedef bsl::allocator< char > allocator_type

Public Member Functions

 BSLMF_NESTED_TRAIT_DECLARATION (TestLoader, bslma::UsesBslmaAllocator)
 TestLoader ()
 TestLoader (const allocator_type &allocator)
virtual ~TestLoader ()
void setTimeZone (const Zoneinfo &timeZone)
int setTimeZone (const char *timeZoneId, const char *timeZoneData, int timeZoneDataNumBytes)
virtual int loadTimeZone (Zoneinfo *result, const char *timeZoneId)
allocator_type get_allocator () const
bsl::ostream & print (bsl::ostream &stream, int level=0, int spacesPerLevel=4) const

Detailed Description

This class provides a concrete test implementation of the Loader protocol (an abstract interface) for obtaining a time zone. This test implementation maintains a mapping of time-zone identifiers to Zoneinfo objects. Time zone information objects are associated with a time-zone identifier using the setTimeZone method, and can be subsequently accessed by calling the protocol method loadTimeZone with the same identifier.

See Component baltzo_testloader


Member Typedef Documentation


Constructor & Destructor Documentation

baltzo::TestLoader::TestLoader (  ) 
baltzo::TestLoader::TestLoader ( const allocator_type allocator  )  [explicit]

Create a TestLoader object. Optionally specify an allocator (e.g., the address of a bslma::Allocator object) to supply memory; otherwise, the default allocator is used. By default the test loader will return ErrorCode::k_UNSUPPORTED_ID for all time-zone identifiers.

virtual baltzo::TestLoader::~TestLoader (  )  [virtual]

Destroy this TestLoader object;


Member Function Documentation

baltzo::TestLoader::BSLMF_NESTED_TRAIT_DECLARATION ( TestLoader  ,
bslma::UsesBslmaAllocator   
)
void baltzo::TestLoader::setTimeZone ( const Zoneinfo timeZone  ) 

Set, to the specified timeZone, the time-zone information that will be returned by loadTimeZone for the identifier timeZone.identifier().

int baltzo::TestLoader::setTimeZone ( const char *  timeZoneId,
const char *  timeZoneData,
int  timeZoneDataNumBytes 
)

Set the time-zone data this test loader will return for the specified timeZoneId to the Zoneinfo value defined by reading the specified timeZoneData buffer, holding data in the Zoneinfo standard binary file format, of at least the specified timeZoneDataNumBytes. Return 0 on success, or a negative value if an error occurs. The behavior is undefined unless timeZoneData contains at least timeZoneDataNumBytes bytes.

virtual int baltzo::TestLoader::loadTimeZone ( Zoneinfo result,
const char *  timeZoneId 
) [virtual]

Load into the specified result the time-zone information for the time-zone identified by the specified timeZoneId. Return 0 on success, and a non-zero value otherwise. A return status of ErrorCode::k_UNSUPPORTED_ID indicates that timeZoneId is not recognized. If an error occurs during the operation, result will be left in a valid but unspecified state.

Implements baltzo::Loader.

allocator_type baltzo::TestLoader::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.

bsl::ostream& baltzo::TestLoader::print ( bsl::ostream &  stream,
int  level = 0,
int  spacesPerLevel = 4 
) const

Write the set of time zones maintained by this object to the specified output stream in a human-readable format, and return a reference to stream. Optionally specify an initial indentation level, whose absolute value is incremented recursively for nested objects. If level is specified, optionally specify spacesPerLevel, whose absolute value indicates the number of spaces per indentation level for this and all of its nested objects. If level is negative, suppress indentation of the first line. If spacesPerLevel is negative, format the entire output on one line, suppressing all but the initial indentation (as governed by level). If stream is not valid on entry, this operation has no effect. Note that the format is not fully specified, and can change without notice.


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