lipsum-cpp 0.5.4
A basic library written in C++ for generating placeholder Lorem Ipsum text.
Loading...
Searching...
No Matches
lipsum::internal Namespace Reference

This namespace contains functions only used internally by other functions. More...

Concepts

concept  ToStringable
 Can std::to_string() be called with T?
concept  Streamable
 Can std::ostream take T?
concept  IsInt
 Is T an int?
concept  UniformDistributionType
 Can std::uniform_int_distribution or std::uniform_real_distribution be constructed with T?

Enumerations

enum class  LogType : int {
  Trace = 0 , Info , Warn , Error ,
  Critical
}
 Log types for lipsum::internal::LogWarn(). More...

Functions

LIPSUM_API std::string HandleHTMLEntity (char letter, Format format=Format::HTML)
 Handle HTML entities.
template<typename... Args>
void LogWarn (LogType type, const Args &... args)
 Log a warning.
template<Streamable T>
std::string ToString (const T &param)
 Convert an object to a string.
template<ToStringable T>
std::string ToString (const T &param)
template<typename T>
ToType (const std::string &input)
 Convert a string to an object.

Detailed Description

This namespace contains functions only used internally by other functions.

This namespace's functions are not intended for public use and are not exposed in the C wrapper.

Enumeration Type Documentation

◆ LogType

enum class lipsum::internal::LogType : int
strong

Log types for lipsum::internal::LogWarn().

Since
0.5.2

Function Documentation

◆ HandleHTMLEntity()

std::string lipsum::internal::HandleHTMLEntity ( char letter,
Format format = Format::HTML )

Handle HTML entities.

Since
0.0.6

Handle escaping HTML entities, escaping Markdown characters, etc.

Parameters
letterThe character to handle.
formatThe format to escape in.
Returns
The handled string.

◆ LogWarn()

template<typename... Args>
void lipsum::internal::LogWarn ( LogType type,
const Args &... args )

Log a warning.

Since
0.4.2

Log to the console coloured using ANSI escape codes with a message, ending in a newline. If in Emscripten environment, use JavaScript console functions instead. If in Windows environment, use SetConsoleTextAttribute() instead. If doing a minimum build, skip colouring text or logging in JS console. If doing a quiet build, do not print.

Template Parameters
ArgsThe arguments' types. All must be printable with std::ostream, or else the code will fail to compile.
Parameters
typeThe log type of the message.
argsThe arguments to print.

◆ ToString()

template<Streamable T>
std::string lipsum::internal::ToString ( const T & param)

Convert an object to a string.

Since
0.3.0

This function converts the parameter passed into a string using std::stringstream or std::to_string().

Template Parameters
TThe type being converted. Must be printable using std::stringstream or convertable using std::to_string().
Parameters
paramThe parameter being converted.
Returns
std::string The parameter as a string.

◆ ToType()

template<typename T>
T lipsum::internal::ToType ( const std::string & input)

Convert a string to an object.

Since
0.4.6

This function converts the string passed into the specified type. If T is std::string, return input. If T is bool, return based on if input is true/1 or false/0. If T is char, get first character of the string or a null character if the string is empty. If T is an integer type, convert using std::from_chars(). Else, convert using std::stringstream.

Template Parameters
TThe type being converted to.
Parameters
inputThe string being converted.
Returns
T The string as the type.