BDE 4.14.0 Production release
Loading...
Searching...
No Matches
ball::UserFieldValue Class Reference

#include <ball_userfieldvalue.h>

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 ()=default
 Destroy this object.
 
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 ball_userfieldvalue

Constructor & Destructor Documentation

◆ UserFieldValue() [1/8]

ball::UserFieldValue::UserFieldValue ( bslma::Allocator basicAllocator = 0)
inlineexplicit

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.

◆ UserFieldValue() [2/8]

ball::UserFieldValue::UserFieldValue ( bsls::Types::Int64  value,
bslma::Allocator basicAllocator = 0 
)
inlineexplicit

◆ UserFieldValue() [3/8]

ball::UserFieldValue::UserFieldValue ( double  value,
bslma::Allocator basicAllocator = 0 
)
inlineexplicit

◆ UserFieldValue() [4/8]

ball::UserFieldValue::UserFieldValue ( const bsl::string_view value,
bslma::Allocator basicAllocator = 0 
)
inlineexplicit

◆ UserFieldValue() [5/8]

ball::UserFieldValue::UserFieldValue ( const bdlt::DatetimeTz value,
bslma::Allocator basicAllocator = 0 
)
inlineexplicit

◆ UserFieldValue() [6/8]

ball::UserFieldValue::UserFieldValue ( const bsl::vector< char > &  value,
bslma::Allocator basicAllocator = 0 
)
inlineexplicit

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.

◆ UserFieldValue() [7/8]

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 
)
inlineexplicit

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.

◆ UserFieldValue() [8/8]

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

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.

◆ ~UserFieldValue()

ball::UserFieldValue::~UserFieldValue ( )
default

Member Function Documentation

◆ allocator()

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

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.

◆ BSLMF_NESTED_TRAIT_DECLARATION()

ball::UserFieldValue::BSLMF_NESTED_TRAIT_DECLARATION ( UserFieldValue  ,
bslma::UsesBslmaAllocator   
)

◆ isUnset()

bool ball::UserFieldValue::isUnset ( ) const
inline

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.

◆ operator=()

UserFieldValue & ball::UserFieldValue::operator= ( const UserFieldValue rhs)
inline

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

◆ print()

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.

◆ reset()

void ball::UserFieldValue::reset ( )
inline

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

◆ setCharArray()

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

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

◆ setDatetimeTz()

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

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

◆ setDouble()

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

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

◆ setInt64()

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

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

◆ setString()

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

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

◆ swap()

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

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.

◆ theCharArray()

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

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.

◆ theDatetimeTz()

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

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

◆ theDouble()

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

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

◆ theInt64()

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

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.

◆ theString()

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

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

◆ type()

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.

Friends And Related Symbol Documentation

◆ operator==

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.

◆ swap

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: