Quick Links:

bal | bbl | bdl | bsl

Public Member Functions | Friends

ball::UserFieldValue Class Reference

#include <ball_userfieldvalue.h>

List of all members.

Public Member Functions

 BSLMF_NESTED_TRAIT_DECLARATION (UserFieldValue, bslma::UsesBslmaAllocator)
 UserFieldValue (bslma::Allocator *basicAllocator=0)
 UserFieldValue (bsls::Types::Int64 value, bslma::Allocator *basicAllocator=0)
 UserFieldValue (double value, bslma::Allocator *basicAllocator=0)
 UserFieldValue (const bsl::string_view &value, bslma::Allocator *basicAllocator=0)
 UserFieldValue (const bdlt::DatetimeTz &value, bslma::Allocator *basicAllocator=0)
 UserFieldValue (const bsl::vector< char > &value, bslma::Allocator *basicAllocator=0)
template<class t_INTEGRAL_TYPE >
 UserFieldValue (t_INTEGRAL_TYPE value, bslma::Allocator *basicAllocator=0, typename bsl::enable_if< bsl::is_integral< t_INTEGRAL_TYPE >::value >::type *=0)
 UserFieldValue (const UserFieldValue &original, bslma::Allocator *basicAllocator=0)
 ~UserFieldValue ()
UserFieldValueoperator= (const UserFieldValue &rhs)
void reset ()
void setInt64 (bsls::Types::Int64 value)
void setDouble (double value)
void setString (const bsl::string_view &value)
void setDatetimeTz (const bdlt::DatetimeTz &value)
void setCharArray (const bsl::vector< char > &value)
void swap (UserFieldValue &other)
bool isUnset () const
ball::UserFieldType::Enum type () const
const bsls::Types::Int64theInt64 () const
const double & theDouble () const
const bsl::stringtheString () const
const bdlt::DatetimeTztheDatetimeTz () const
const bsl::vector< char > & theCharArray () const
bslma::Allocatorallocator () const
bsl::ostream & print (bsl::ostream &stream, int level=0, int spacesPerLevel=4) const

Friends

bool operator== (const UserFieldValue &, const UserFieldValue &)
void swap (UserFieldValue &, UserFieldValue &)

Detailed Description

This class implements a value-semantic type for representing the value of a user field in a log record. A user field value acts as a discriminated union, and may represent a value of any of the types described in ball::UserFieldType or an unset value (indicated by type ball::UserFieldType::e_VOID).

See Component ball_userfieldvalue


Constructor & Destructor Documentation

ball::UserFieldValue::UserFieldValue ( bslma::Allocator basicAllocator = 0  )  [explicit]

Create a user field value having the unset value. Optionally specify a basicAllocator used to supply memory. If basicAllocator is 0, the currently installed default allocator is used.

ball::UserFieldValue::UserFieldValue ( bsls::Types::Int64  value,
bslma::Allocator basicAllocator = 0 
) [explicit]
ball::UserFieldValue::UserFieldValue ( double  value,
bslma::Allocator basicAllocator = 0 
) [explicit]
ball::UserFieldValue::UserFieldValue ( const bsl::string_view &  value,
bslma::Allocator basicAllocator = 0 
) [explicit]
ball::UserFieldValue::UserFieldValue ( const bdlt::DatetimeTz value,
bslma::Allocator basicAllocator = 0 
) [explicit]
ball::UserFieldValue::UserFieldValue ( const bsl::vector< char > &  value,
bslma::Allocator basicAllocator = 0 
) [explicit]

Create a user field value having the specified value. Optionally specify a basicAllocator used to supply memory. If basicAllocator is 0, the currently installed default allocator is used.

template<class t_INTEGRAL_TYPE >
ball::UserFieldValue::UserFieldValue ( t_INTEGRAL_TYPE  value,
bslma::Allocator basicAllocator = 0,
typename bsl::enable_if< bsl::is_integral< t_INTEGRAL_TYPE >::value >::type = 0 
) [inline, explicit]

Create a user field value having the specified integral value. Optionally specify a basicAllocator used to supply memory. If basicAllocator is 0, the currently installed default allocator is used.

Note that this constructor is provided to disambiguate between constructors taking double and bsls::Types::Int64 when supplied an integer that is not of type bsls::Types::Int64. Also note that the implementation is (temporarily) provided inline to avoid issues with MSVC 2008.

ball::UserFieldValue::UserFieldValue ( const UserFieldValue original,
bslma::Allocator basicAllocator = 0 
)

Create a UserFieldValue object having the same value as the specified original object. Optionally specify a basicAllocator used to supply memory. If basicAllocator is 0, the currently installed default allocator is used.

ball::UserFieldValue::~UserFieldValue (  ) 

Destroy this object.


Member Function Documentation

ball::UserFieldValue::BSLMF_NESTED_TRAIT_DECLARATION ( UserFieldValue  ,
bslma::UsesBslmaAllocator   
)
UserFieldValue& ball::UserFieldValue::operator= ( const UserFieldValue rhs  ) 

Assign to this object the value of the specified rhs object, and return a reference providing modifiable access to this object.

void ball::UserFieldValue::reset (  ) 

Set this object to have the unset value. After this operation, type() == ball::UserFieldType::e_VOID.

void ball::UserFieldValue::setInt64 ( bsls::Types::Int64  value  ) 

Set this object to have the specified value. After this operation, type() == ball::UserFieldType::e_INT64.

void ball::UserFieldValue::setDouble ( double  value  ) 

Set this object to have the specified value. After this operation, type() == ball::UserFieldType::e_DOUBLE.

void ball::UserFieldValue::setString ( const bsl::string_view &  value  ) 

Set this object to have the specified value. After this operation, type() == ball::UserFieldType::e_STRING.

void ball::UserFieldValue::setDatetimeTz ( const bdlt::DatetimeTz value  ) 

Set this object to have the specified value. After this operation, type() == ball::UserFieldType::e_DATETIMETZ.

void ball::UserFieldValue::setCharArray ( const bsl::vector< char > &  value  ) 

Set this object to have the specified value. After this operation, type() == ball::UserFieldType::e_CHAR_ARRAY.

void ball::UserFieldValue::swap ( UserFieldValue other  ) 

Efficiently exchange the value of this object with the value of the specified other object. This method provides the no-throw exception-safety guarantee if either type() is the same as other.type(), or neither type() nor other.type() is a type that requires allocation; otherwise, it provides the basic guarantee. The behavior is undefined unless this object was created with the same allocator as other.

bool ball::UserFieldValue::isUnset (  )  const

Return true if this object has the unset value, and false otherwise. Note that if isUnset() returns true, then type() returns ball::UserFieldType::e_VOID.

ball::UserFieldType::Enum ball::UserFieldValue::type (  )  const

Return the type of this user field value. The type ball::UserFieldValue::e_VOID represents the unset value.

const bsls::Types::Int64& ball::UserFieldValue::theInt64 (  )  const

Return a reference providing non-modifiable access to the 64-bit integer value of this object. The behavior is undefined unless type() == ball::UserFieldType::e_INT64.

const double& ball::UserFieldValue::theDouble (  )  const

Return a reference providing non-modifiable access to the double value of this object. The behavior is undefined unless type() == ball::UserFieldType::e_DOUBLE.

const bsl::string& ball::UserFieldValue::theString (  )  const

Return a reference providing non-modifiable access to the string value of this object. The behavior is undefined unless type() == ball::UserFieldType::e_STRING.

const bdlt::DatetimeTz& ball::UserFieldValue::theDatetimeTz (  )  const

Return a reference providing non-modifiable access to the DatetimeTz value of this object. The behavior is undefined unless type() == ball::UserFieldType::e_DATETIMETZ.

const bsl::vector<char>& ball::UserFieldValue::theCharArray (  )  const

Return a reference providing non-modifiable access to the bsl::vector<char> value of this object. The behavior is undefined unless type() == ball::UserFieldType::e_CHAR_ARRAY.

bslma::Allocator* ball::UserFieldValue::allocator (  )  const

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

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

Write the value of 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.


Friends And Related Function Documentation

bool operator== ( const UserFieldValue ,
const UserFieldValue  
) [friend]

Return true if the specified lhs and rhs objects have the same value, and false otherwise. Two UserFieldValue objects have the same value if they have the same type, and (if the type is not e_VOID) the value of that type (as accessed through the* methods) is the same.

void swap ( UserFieldValue ,
UserFieldValue  
) [friend]

Swap the value of the specified a object with the value of the specified b object. This method provides the no-throw exception-safety guarantee if either a.type() is the same as b.type() and a and b were created with the same allocator, or neither a.type() nor b.type() is a type that requires allocation; otherwise, it provides the basic guarantee.


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