Giter VIP home page Giter VIP logo

cpptoolkit-io's Introduction

Input / Output Utility (IO) for C++

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

This utility has some limitation due to the following:

  • In log() and logLn(), a built-in function that might exclusively available for gcc is used to obtain the name of the function: __builtin_FUNCTION(). This may result in compile errors when using on other compilers than gcc.

Usage

  • 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 to std:cerr or std:cout. Default: false (std::cout)

    • revealFuncName is a flag for you to control whether the name of the function that called the log() should be included in the output. Default: true

    • timestamping is a flag for you to control whether the time should be displayed when the function log() is called.

    • custFuncName is the string for the name of the function calling log(). 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 adds std::endl at the end of every output of log().

    • Returns void

  • out(std::string/char* message)

    • Outputs message to std::cout

    • Returns void

  • outLn(std::string/char* message)

    • Acts the same as out(), but it adds std::endl at the end of every output of out()

    • Returns void

  • err(std::string/char* message)

    • Outputs message to std::cerr

    • Returns void

  • errLn(std::string/char* message)

    • Acts the same as out(), but it adds std::endl at the end of every output of err()
  • 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 return std::string or char*. 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 in inSafe(). Currently, it supports the following data types:

        • std::string, or string

        • 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 use std::getline() instead of std::cin to obtain input. When isGetLine is set to true, the data type is limited to

        • std::string or string

        • char*

cpptoolkit-io's People

Contributors

tlchiu40209 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.