Sane C++ Libraries
C++ Platform Abstraction Libraries
SC::Console Struct Reference

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

#include <Console.h>

Public Member Functions

 Console (Vector< char > &encodingConversionBuffer)
 Constructs a console with a conversion buffer used for string conversions (UTF8 / UTF16) More...
 
template<typename... Types>
bool print (StringView fmt, Types &&... args)
 Prints a formatted string using SC::StringFormat. More...
 
void print (const StringView str)
 Prints a StringView to console. More...
 
void printLine (const StringView str)
 Prints a StringView to console and adds a newline at the end of it. More...
 

Static Public Member Functions

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

Detailed Description

Writes to console using SC::StringFormat.

Example:

// Create a buffer used for UTF conversions (if necessary)
SmallVector<char, 512 * sizeof(native_char_t)> consoleConversionBuffer;
// Construct console with the buffer
String str = StringView("Test Test\n");
// Have fun printing
console.print(str.view());
char native_char_t
The native char for the platform (wchar_t (4 bytes) on Windows, char (1 byte) everywhere else )
Definition: PrimitiveTypes.h:34

Constructor & Destructor Documentation

◆ Console()

SC::Console::Console ( Vector< char > &  encodingConversionBuffer)

Constructs a console with a conversion buffer used for string conversions (UTF8 / UTF16)

Parameters
encodingConversionBufferThe 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 StringView  str)

Prints a StringView to console.

Parameters
strThe StringView to print

◆ print() [2/2]

template<typename... Types>
bool SC::Console::print ( StringView  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 StringView  str)

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

Parameters
strThe StringView 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: