Pretty Diagnostics
Create your own pretty diagnostics
Loading...
Searching...
No Matches
pretty_diagnostics::Label Class Reference

Represents a short textual annotation attached to a Span in a source. More...

#include <label.hpp>

Public Member Functions

 Label (std::string text, Span span)
 Constructs a label with a human-readable message and the span it refers to. More...
 
const std::string & text () const
 Returns the label text. More...
 
const Spanspan () const
 Returns the span associated with this label. More...
 

Friends

bool operator< (const Label &lhs, const Label &rhs)
 Orders labels by their span to allow placement within a line/group. More...
 
bool operator<= (const Label &lhs, const Label &rhs)
 Less-than-or-equal comparison derived from >= More...
 
bool operator> (const Label &lhs, const Label &rhs)
 Greater-than comparison derived from < More...
 
bool operator>= (const Label &lhs, const Label &rhs)
 Greater-than-or-equal comparison derived from < More...
 

Detailed Description

Represents a short textual annotation attached to a Span in a source.

Labels are ordered by their underlying Span to support stable grouping and rendering of diagnostics

Constructor & Destructor Documentation

◆ Label()

pretty_diagnostics::Label::Label ( std::string  text,
Span  span 
)

Constructs a label with a human-readable message and the span it refers to.

Parameters
textShort message to display next to the span in the rendered output
spanSource span this label highlights

Member Function Documentation

◆ span()

const Span & pretty_diagnostics::Label::span ( ) const
inline

Returns the span associated with this label.

Returns
Span this label highlights

◆ text()

const std::string & pretty_diagnostics::Label::text ( ) const
inline

Returns the label text.

Returns
Human-readable message associated with this label

Friends And Related Function Documentation

◆ operator<

bool operator< ( const Label lhs,
const Label rhs 
)
friend

Orders labels by their span to allow placement within a line/group.

Parameters
lhsLeft-hand label
rhsRight-hand label
Returns
True if lhs's span starts before rhs's span

◆ operator<=

bool operator<= ( const Label lhs,
const Label rhs 
)
friend

Less-than-or-equal comparison derived from >=

Parameters
lhsLeft-hand label
rhsRight-hand label
Returns
True if lhs is not greater than rhs

◆ operator>

bool operator> ( const Label lhs,
const Label rhs 
)
friend

Greater-than comparison derived from <

Parameters
lhsLeft-hand label
rhsRight-hand label
Returns
True if lhs is ordered after rhs

◆ operator>=

bool operator>= ( const Label lhs,
const Label rhs 
)
friend

Greater-than-or-equal comparison derived from <

Parameters
lhsLeft-hand label
rhsRight-hand label
Returns
True if lhs is not less than rhs

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