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

Represents a fully constructed diagnostic report to be rendered. More...

#include <report.hpp>

Data Structures

class  Builder
 Fluent builder for constructing Report instances. More...
 

Public Types

using MappedFileGroups = std::unordered_map< std::shared_ptr< Source >, FileGroup >
 

Public Member Functions

 Report (std::string message, std::optional< std::string > code, Severity severity, MappedFileGroups file_groups, std::optional< std::string > note, std::optional< std::string > help)
 Constructs a report. More...
 
void render (IReporterRenderer &renderer, std::ostream &stream=std::cout) const
 Renders the report using the provided renderer to the output stream. More...
 
const MappedFileGroupsfile_groups () const
 Returns the mapping of sources to file groups. More...
 
MappedFileGroupsfile_groups ()
 Returns the mapping of sources to file groups. More...
 
Severity severity () const
 Returns the severity of this report. More...
 
const std::string & message () const
 Returns the primary diagnostic message. More...
 
const std::optional< std::string > & note () const
 Returns an optional note with additional context. More...
 
const std::optional< std::string > & help () const
 Returns optional help text with suggestions. More...
 
const std::optional< std::string > & code () const
 Returns an optional error code or identifier. More...
 

Detailed Description

Represents a fully constructed diagnostic report to be rendered.

Member Typedef Documentation

◆ MappedFileGroups

using pretty_diagnostics::Report::MappedFileGroups = std::unordered_map<std::shared_ptr<Source>, FileGroup>

Constructor & Destructor Documentation

◆ Report()

pretty_diagnostics::Report::Report ( std::string  message,
std::optional< std::string >  code,
Severity  severity,
MappedFileGroups  file_groups,
std::optional< std::string >  note,
std::optional< std::string >  help 
)

Constructs a report.

Parameters
messagePrimary diagnostic message
codeOptional error code or identifier
severityDiagnostic severity
file_groupsMapping from sources to their file group
noteOptional note for additional context
helpOptional help text with suggestions

Member Function Documentation

◆ code()

const std::optional< std::string > & pretty_diagnostics::Report::code ( ) const
inline

Returns an optional error code or identifier.

Returns
Optional code string

◆ file_groups() [1/2]

MappedFileGroups & pretty_diagnostics::Report::file_groups ( )
inline

Returns the mapping of sources to file groups.

Returns
Reference to mapped file groups

◆ file_groups() [2/2]

const MappedFileGroups & pretty_diagnostics::Report::file_groups ( ) const
inline

Returns the mapping of sources to file groups.

Returns
Reference to mapped file groups

◆ help()

const std::optional< std::string > & pretty_diagnostics::Report::help ( ) const
inline

Returns optional help text with suggestions.

Returns
Optional help string

◆ message()

const std::string & pretty_diagnostics::Report::message ( ) const
inline

Returns the primary diagnostic message.

Returns
Message string

◆ note()

const std::optional< std::string > & pretty_diagnostics::Report::note ( ) const
inline

Returns an optional note with additional context.

Returns
Optional note string

◆ render()

void pretty_diagnostics::Report::render ( IReporterRenderer renderer,
std::ostream &  stream = std::cout 
) const

Renders the report using the provided renderer to the output stream.

Parameters
rendererRenderer implementation
streamOutput stream to write to (defaults to std::cout)

◆ severity()

Severity pretty_diagnostics::Report::severity ( ) const
inline

Returns the severity of this report.

Returns
Report severity

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