wayne::IO is a bunch of tools related to input/output operation.
Access these functions by adding namespace:
wayne::IO::
This utility also relies on the following libraries
wayne::strUtil::
, Click Here
This utility has some limitation due to the following:
- In
log() and logLn()
, a built-in function that might exclusively available forgcc
is used to obtain the name of the function:__builtin_FUNCTION()
. This may result in compile errors when using on other compilers thangcc
.
-
log(std::string/char* message, bool isError(Optional), bool revealFuncName(Optional), bool timestamping(Optional), std::string custFuncName)
-
Providing a log-like output for your program. The output will include:
-
The name of the function that called the
log()
function. -
The time when
log()
function was called.
-
-
isError
is a flag for you to control whether the output should either place tostd:cerr
orstd:cout
. Default:false (std::cout)
-
revealFuncName
is a flag for you to control whether the name of the function that called thelog()
should be included in the output. Default:true
-
timestamping
is a flag for you to control whether the time should be displayed when the functionlog()
is called. -
custFuncName
is the string for the name of the function callinglog()
. The default value is__builtin_FUNCTION()
. You can customize the function name as you like. -
Returns
void
-
-
logLn(std::string/char* message, bool isError(Optional), bool revealFuncName(Optional), bool timestamping(Optional), std::string custFuncName)
-
Acts the same as
log()
, but it addsstd::endl
at the end of every output oflog()
. -
Returns
void
-
-
out(std::string/char* message)
-
Outputs
message
tostd::cout
-
Returns
void
-
-
outLn(std::string/char* message)
-
Acts the same as
out()
, but it addsstd::endl
at the end of every output ofout()
-
Returns
void
-
-
err(std::string/char* message)
-
Outputs
message
tostd::cerr
-
Returns
void
-
-
errLn(std::string/char* message)
- Acts the same as
out()
, but it addsstd::endl
at the end of every output oferr()
- Acts the same as
-
inSafe(std::string/char* expectingDataType, int amountOfLetters, std::string/char* fromOptions, bool isGetLine = true)
-
Acts similar to
std::cin
with additional criteria for the ease of input and overflow protection. Please Note: Though expected data type is provided to the function, it will still either returnstd::string
orchar*
. You must convert the returned value manually to the data type you would like to use. -
std::string/char* expectingDataType
-
It tells
inSafe()
what data type you are expecting to be inputed. Different data type may trigger different checking mechanism ininSafe()
. Currently, it supports the following data types:-
std::string
, orstring
-
char*
-
int
-
long
-
float
-
double
-
-
-
int amountOfLetters
-
It tells
inSafe()
the amount of letters / digits it is going to accept. Any input length that is greater than the defined amount, will be cut. -
To disable the input limitation, set
amountOfLetters = 0, or -1
-
-
std::string/char* fromOptions
-
It tells
inSafe()
the valid input options. Each option should be divided by,
without any space in between. -
Example: "apple,banana,citrius"
-
If the user didn't input anything that matched,
inSafe
will return empty string.
-
-
bool isGetLine
-
It tells
inSafe()
to usestd::getline()
instead ofstd::cin
to obtain input. WhenisGetLine
is set to true, the data type is limited to-
std::string
orstring
-
char*
-
-
-