Contains useful set of functions to print errors, warning, check existence of files, etc.
More...
#include <iostream>
#include <fstream>
#include "OutputColor.hpp"
Go to the source code of this file.
|
| void | CppTools::PrintError (const std::string &message, const bool exitProgram=true) |
| | Prints error prompt.
|
| void | CppTools::PrintWarning (const std::string &message) |
| | Prints warning prompt.
|
| bool | CppTools::FileExists (const std::string &name) |
| | Returns true if the file exists, else false.
|
| bool | CppTools::CheckInputFile (const std::string &name, const bool closeAfterFail=true) |
| | Checks whether the file exists or not If files exists the function does nothing, else it prints error or warning.
|
| void | CppTools::CheckOutputFile (const std::string &name, const bool closeAfterFail=true, const std::ios_base::openmode openmode=std::ios::out) |
| | Checks whether the file can be created If files exists the function does nothing, else it prints error or warning.
|
|
|
const std::string | CppTools::ERROR_PROMPT = COLOR_RED + " ERROR: " + COLOR_WHITE |
| | String containing red text "ERROR".
|
|
const std::string | CppTools::WARNING_PROMPT = COLOR_MAGENTA + " WARNING: " + COLOR_RESET |
| | String containing magenta text "WARNING".
|
|
const std::string | CppTools::INFO_PROMPT = " [ " + COLOR_GREEN + "INFO" + COLOR_RESET + " ] " |
| | String containing green text "INFO".
|
Contains useful set of functions to print errors, warning, check existence of files, etc.
In order to use functions from this file libErrorHandler.so must be loaded
This file is a part of a project CppTools (https://github.com/Sergeyir/CppTools).
- Author
- Sergei Antsupov (antsu.nosp@m.pov0.nosp@m.124@g.nosp@m.mail.nosp@m..com)
◆ CheckInputFile()
| bool CppTools::CheckInputFile |
( |
const std::string & | name, |
|
|
const bool | closeAfterFail = true ) |
Checks whether the file exists or not If files exists the function does nothing, else it prints error or warning.
- Parameters
-
| [in] | name | name of file to be checked |
| [in] | closeAfterFail | if true and if file does not exist function prints error and calls exit(1); if false and file does not exist function simply prints warning |
◆ CheckOutputFile()
| void CppTools::CheckOutputFile |
( |
const std::string & | name, |
|
|
const bool | closeAfterFail = true, |
|
|
const std::ios_base::openmode | openmode = std::ios::out ) |
Checks whether the file can be created If files exists the function does nothing, else it prints error or warning.
- Parameters
-
| [in] | name | name of file to be checked |
| [in] | closeAfterFail | if true and if file cannot be created function prints error and calls exit(1); if false and file cannot be created function simply prints warning |
| [in] | openmode | used for constructor of ofstream |
◆ FileExists()
| bool CppTools::FileExists |
( |
const std::string & | name | ) |
|
Returns true if the file exists, else false.
- Parameters
-
| [in] | name | name of file to be checked |
◆ PrintError()
| void CppTools::PrintError |
( |
const std::string & | message, |
|
|
const bool | exitProgram = true ) |
Prints error prompt.
- Parameters
-
| [in] | message | text to print in the error prompt |
| [in] | exitProgram | if true the function calls exit(1) after printing error prompt |
◆ PrintWarning()
| void CppTools::PrintWarning |
( |
const std::string & | message | ) |
|
Prints warning prompt.
- Parameters
-
| [in] | message | text to print in the error prompt |