Sane C++ Libraries
C++ Platform Abstraction Libraries
Loading...
Searching...
No Matches
SC::Console Struct Reference

Writes to console using SC::StringFormat. More...

#include <Console.h>

Public Member Functions

 Console (Span< char > conversionBuffer={})
 Constructs a console with an OPTIONAL conversion buffer used for UTF encoding conversions on Windows.
 
template<typename... Types>
bool print (StringSpan fmt, Types &&... args)
 Prints a formatted string using SC::StringFormat.
 
void print (const StringSpan str)
 Prints a StringSpan to console.
 
void printLine (const StringSpan str)
 Prints a StringSpan to console and adds a newline at the end of it.
 

Static Public Member Functions

static bool tryAttachingToParentConsole ()
 Tries attaching current process to parent console (Windows only, has no effect elsewhere)
 
static bool isAttachedToConsole ()
 Returns true if current process has an active console (Windows only, returns true elsewhere)
 

Detailed Description

Writes to console using SC::StringFormat.

Example:

// Use a custom buffer UTF conversions on windows (optional)
char optionalConversionBuffer[512];
Console console(optionalConversionBuffer);
String str = StringView("Test Test\n");
// Have fun printing
console.print(str.view());
Writes to console using SC::StringFormat.
Definition Console.h:25
Non-owning view over a range of characters with UTF Encoding.
Definition StringView.h:46
A non-modifiable owning string with associated encoding.
Definition String.h:29
StringView view() const SC_LANGUAGE_LIFETIME_BOUND
Obtain a null-terminated StringView from current String.

Constructor & Destructor Documentation

◆ Console()

SC::Console::Console ( Span< char > conversionBuffer = {})

Constructs a console with an OPTIONAL conversion buffer used for UTF encoding conversions on Windows.

Parameters
conversionBufferThe optional buffer used for UTF conversions

Member Function Documentation

◆ isAttachedToConsole()

static bool SC::Console::isAttachedToConsole ( )
static

Returns true if current process has an active console (Windows only, returns true elsewhere)

◆ print() [1/2]

void SC::Console::print ( const StringSpan str)

Prints a StringSpan to console.

Parameters
strThe StringSpan to print

◆ print() [2/2]

template<typename... Types>
bool SC::Console::print ( StringSpan fmt,
Types &&... args )
inline

Prints a formatted string using SC::StringFormat.

Template Parameters
TypesTypes of args
Parameters
fmtFormat string
argsArguments to be formatted in the string
Returns
true if message has been printed successfully to Console

◆ printLine()

void SC::Console::printLine ( const StringSpan str)

Prints a StringSpan to console and adds a newline at the end of it.

Parameters
strThe StringSpan to print

◆ tryAttachingToParentConsole()

static bool SC::Console::tryAttachingToParentConsole ( )
static

Tries attaching current process to parent console (Windows only, has no effect elsewhere)

Returns
true if the parent console has been attached (Windows only, returns true elsewhere)

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