Quick Links:

bal | bbl | bdl | bsl

Public Member Functions | Friends

ball::RecordAttributes Class Reference

#include <ball_recordattributes.h>

List of all members.

Public Member Functions

 BSLMF_NESTED_TRAIT_DECLARATION (RecordAttributes, bslma::UsesBslmaAllocator)
 RecordAttributes (bslma::Allocator *basicAllocator=0)
 RecordAttributes (const bdlt::Datetime &timestamp, int processID, bsls::Types::Uint64 threadID, const char *fileName, int lineNumber, const char *category, int severity, const char *message, bslma::Allocator *basicAllocator=0)
 RecordAttributes (const RecordAttributes &original, bslma::Allocator *basicAllocator=0)
 ~RecordAttributes ()
RecordAttributesoperator= (const RecordAttributes &rhs)
void clearMessage ()
bdlsb::MemOutStreamBufmessageStreamBuf ()
void setCategory (const char *category)
void setFileName (const char *fileName)
void setLineNumber (int lineNumber)
void setMessage (const char *message)
void setProcessID (int processID)
void setSeverity (int severity)
void setThreadID (bsls::Types::Uint64 threadID)
void setTimestamp (const bdlt::Datetime &timestamp)
const char * category () const
const char * fileName () const
int lineNumber () const
const char * message () const
bslstl::StringRef messageRef () const
int processID () const
int severity () const
bsls::Types::Uint64 threadID () const
const bdlt::Datetimetimestamp () const
const bdlsb::MemOutStreamBufmessageStreamBuf () const
bsl::ostream & print (bsl::ostream &stream, int level=0, int spacesPerLevel=4) const

Friends

bool operator== (const RecordAttributes &, const RecordAttributes &)

Detailed Description

This class provides a container for a fixed set of attributes appropriate for logging. For each attribute in this class (e.g., category), there is an accessor for obtaining the attribute's value (the category accessor) and a manipulator for changing the attribute's value (the setCategory manipulator).

Additionally, this class supports a complete set of value semantic operations, including copy construction, assignment and equality comparison, and ostream printing. A precise operational definition of when two instances have the same value can be found in the description of operator== for the class. This class is exception neutral with no guarantee of rollback: If an exception is thrown during the invocation of a method on a pre-existing instance, the object is left in a valid state, but its value is undefined. In no event is memory leaked. Finally, aliasing (e.g., using all or part of an object as both source and destination) is supported in all cases.

See Component ball_recordattributes


Constructor & Destructor Documentation

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

Create a record attributes object with all attributes having default values. Optionally specify a basicAllocator used to supply memory. If basicAllocator is 0, the currently installed default allocator is used.

ball::RecordAttributes::RecordAttributes ( const bdlt::Datetime timestamp,
int  processID,
bsls::Types::Uint64  threadID,
const char *  fileName,
int  lineNumber,
const char *  category,
int  severity,
const char *  message,
bslma::Allocator basicAllocator = 0 
)

Create a record attributes object having the specified timestamp, processID, threadID, fileName, lineNumber, category, severity and message values, respectively. Optionally specify a basicAllocator used to supply memory. If basicAllocator is 0, the currently installed default allocator is used. The behavior is undefined if any const char * argument is null.

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

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

ball::RecordAttributes::~RecordAttributes (  ) 

Destroy this record attributes object.


Member Function Documentation

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

Assign to this record attributes object the value of the specified rhs record attributes object.

void ball::RecordAttributes::clearMessage (  ) 

Set the message attribute of this record attributes object to the empty string.

bdlsb::MemOutStreamBuf& ball::RecordAttributes::messageStreamBuf (  ) 

Return a reference to the modifiable stream buffer associated with the message attribute of this record attributes object.

void ball::RecordAttributes::setCategory ( const char *  category  ) 

Set the category attribute of this record attributes object to the specified (non-null) category.

void ball::RecordAttributes::setFileName ( const char *  fileName  ) 

Set the filename attribute of this record attributes object to the specified (non-null) fileName.

void ball::RecordAttributes::setLineNumber ( int  lineNumber  ) 

Set the line number attribute of this record attributes object to the specified lineNumber.

void ball::RecordAttributes::setMessage ( const char *  message  ) 

Set the message attribute of this record attributes object to the specified (non-null) message.

void ball::RecordAttributes::setProcessID ( int  processID  ) 

Set the processID attribute of this record attributes object to the specified processID.

void ball::RecordAttributes::setSeverity ( int  severity  ) 

Set the severity attribute of this record attributes object to the specified severity.

void ball::RecordAttributes::setThreadID ( bsls::Types::Uint64  threadID  ) 

Set the threadID attribute of this record attributes object to the specified threadID.

void ball::RecordAttributes::setTimestamp ( const bdlt::Datetime timestamp  ) 

Set the timestamp attribute of this record attributes object to the specified timestamp.

const char* ball::RecordAttributes::category (  )  const

Return the category attribute of this record attributes object.

const char* ball::RecordAttributes::fileName (  )  const

Return the filename attribute of this record attributes object.

int ball::RecordAttributes::lineNumber (  )  const

Return the line number attribute of this record attributes object.

const char* ball::RecordAttributes::message (  )  const

Return the message attribute of this record attributes object. Note that this method will return a truncated message if it contains embedded null (\0) characters; see messageRef for an alternative to this method. **Warning:** This method is not const thread-safe, and cannot be safely called concurrently.

DEPRECATED: Use messageRef instead.

bslstl::StringRef ball::RecordAttributes::messageRef (  )  const

Return a string reference providing non-modifiable access to the message attribute of this record attributes object. Note that the returned string reference is not null-terminated, and may contain null (\0) characters.

int ball::RecordAttributes::processID (  )  const

Return the processID attribute of this record attributes object.

int ball::RecordAttributes::severity (  )  const

Return the severity attribute of this record attributes object.

bsls::Types::Uint64 ball::RecordAttributes::threadID (  )  const

Return the threadID attribute of this record attributes object.

const bdlt::Datetime& ball::RecordAttributes::timestamp (  )  const

Return the timestamp attribute of this record attributes object.

const bdlsb::MemOutStreamBuf& ball::RecordAttributes::messageStreamBuf (  )  const

Return a reference to the non-modifiable stream buffer associated with the message attribute of this record attributes object.

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

Format this object to the specified output stream at the optionally specified indentation level and return a reference to the modifiable stream. If level is specified, optionally specify spacesPerLevel, the number of spaces per indentation level for this and all of its nested objects. Each line is indented by the absolute value of level * spacesPerLevel. If level is negative, suppress indentation of the first line. If spacesPerLevel is negative, suppress line breaks and format the entire output on one line. If stream is initially invalid, this operation has no effect.


Friends And Related Function Documentation

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

Return true if the specified lhs and rhs record attributes objects have the same value, and false otherwise. Two record attributes objects have the same value if each respective pair of attributes have the same value.


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