BDE 4.14.0 Production release
Loading...
Searching...
No Matches
balst::StackTrace Class Reference

#include <balst_stacktrace.h>

Public Member Functions

 BSLMF_NESTED_TRAIT_DECLARATION (StackTrace, bslma::UsesBslmaAllocator)
 
 BSLMF_NESTED_TRAIT_DECLARATION (StackTrace, bslmf::IsBitwiseMoveable)
 
 StackTrace (bslma::Allocator *basicAllocator=0)
 
 StackTrace (const StackTrace &original, bslma::Allocator *basicAllocator=0)
 
 ~StackTrace ()=default
 
StackTraceoperator= (const StackTrace &rhs)
 
StackTraceFrameoperator[] (int index)
 
void append (const StackTraceFrame &value)
 Append to this sequence the specified value.
 
void removeAll ()
 
void resize (int newLength)
 
void swap (StackTrace &other)
 
const StackTraceFrameoperator[] (int index) const
 
int length () const
 Return the number of stack-trace frames contained in this object.
 
bslma::Allocatorallocator () const
 
bsl::ostream & print (bsl::ostream &stream, int level=0, int spacesPerLevel=4) const
 

Friends

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

Detailed Description

This value-semantic class describes a function-call stack, represented as a sequence of randomly accessible StackTraceFrame objects, each of which represents one function call on the stack. Note that if no allocator is supplied at construction, an owned bdlma::HeapBypassAllocator object is used to supply memory.

See balst_stacktrace

Constructor & Destructor Documentation

◆ StackTrace() [1/2]

balst::StackTrace::StackTrace ( bslma::Allocator basicAllocator = 0)
inlineexplicit

Create an empty StackTrace object (having a length of 0). Optionally specify basicAllocator used to supply memory. If basicAllocator is 0, then an owned heap-bypass allocator object is used. Note that the heap-bypass allocator is used by default to avoid heap allocation in situations where the heap may have been corrupted.

◆ StackTrace() [2/2]

balst::StackTrace::StackTrace ( const StackTrace original,
bslma::Allocator basicAllocator = 0 
)
inline

Create a StackTrace object having the same value as the specified original object. Optionally specify a basicAllocator used to supply memory. If basicAllocator is 0, then an owned heap-bypass allocator object is used. Note that the heap-bypass allocator is used by default to avoid heap allocation in situations where the heap may have been corrupted.

◆ ~StackTrace()

balst::StackTrace::~StackTrace ( )
default

Member Function Documentation

◆ allocator()

bslma::Allocator * balst::StackTrace::allocator ( ) const
inline

Return the allocator used by this object to supply memory. Note that if no allocator was supplied at construction the owned heap-bypass allocator is used.

◆ append()

void balst::StackTrace::append ( const StackTraceFrame value)
inline

◆ BSLMF_NESTED_TRAIT_DECLARATION() [1/2]

balst::StackTrace::BSLMF_NESTED_TRAIT_DECLARATION ( StackTrace  ,
bslma::UsesBslmaAllocator   
)

◆ BSLMF_NESTED_TRAIT_DECLARATION() [2/2]

balst::StackTrace::BSLMF_NESTED_TRAIT_DECLARATION ( StackTrace  ,
bslmf::IsBitwiseMoveable   
)

◆ length()

int balst::StackTrace::length ( ) const
inline

◆ operator=()

StackTrace & balst::StackTrace::operator= ( const StackTrace rhs)
inline

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

◆ operator[]() [1/2]

StackTraceFrame & balst::StackTrace::operator[] ( int  index)
inline

Return a reference providing modifiable access to the stack-trace frame at the specified index. The behavior is undefined unless 0 <= index < length().

◆ operator[]() [2/2]

const StackTraceFrame & balst::StackTrace::operator[] ( int  index) const
inline

Return a reference providing non-modifiable access to the stack-trace frame at the specified index. The behavior is undefined unless 0 <= index < length().

◆ print()

bsl::ostream & balst::StackTrace::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.

◆ removeAll()

void balst::StackTrace::removeAll ( )
inline

Remove all stack-trace frames from this object. After this operation, the length() method will return 0.

◆ resize()

void balst::StackTrace::resize ( int  newLength)
inline

Add default constructed stack-trace frames to, or remove stack-trace frames from, the end of this stack-trace object such that, after the operation, length() == newLength. Stack trace frames whose indices are in the range 0 <= index < min(length, newLength) will be unchanged. The behavior is undefined unless 0 <= newLength.

◆ swap()

void balst::StackTrace::swap ( StackTrace 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. The behavior is undefined unless this object was created with the same allocator as other.

Friends And Related Symbol Documentation

◆ operator==

bool operator== ( const StackTrace ,
const StackTrace  
)
friend

Return true if the specified lhs and rhs objects have the same value, and false otherwise. Two StackTrace objects have the same value if they have the save length, and each of their corresponding stack-trace frames have the same value.


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