doc: update documentation in code

This commit is contained in:
yyc12345 2024-07-25 18:15:39 +08:00
parent 31a7cb5675
commit 7f373ed354
6 changed files with 107 additions and 47 deletions

View File

@ -30,7 +30,7 @@ We suggest you to call this function at the beginning of program.
Considering most Linux console supports ASCII Escape Code very well, Considering most Linux console supports ASCII Escape Code very well,
this function does nothing in non-Windows platform. this function does nothing in non-Windows platform.
So it is not essential that brack this function calling with Windows-only \#if. So it is not essential that brack this function calling with Windows-only \c \#if.
\subsection console_helper__color__common Common Usage \subsection console_helper__color__common Common Usage

View File

@ -5,117 +5,158 @@
#include <string> #include <string>
/** /**
* @brief The namespace providing universal Console visiting functions like C-Sharp Console class. * @brief The helper providing universal C\# style console function and other console related stuff
* @details * @details
* \ref console_helper * For how to utilize this functions provided by this namespace, please view \ref console_helper.
*/ */
namespace YYCC::ConsoleHelper { namespace YYCC::ConsoleHelper {
/// @brief The head of ASCII escape code of black color.
#define YYCC_COLORHDR_BLACK "\033[30m" #define YYCC_COLORHDR_BLACK "\033[30m"
/// @brief The head of ASCII escape code of red color.
#define YYCC_COLORHDR_RED "\033[31m" #define YYCC_COLORHDR_RED "\033[31m"
/// @brief The head of ASCII escape code of green color.
#define YYCC_COLORHDR_GREEN "\033[32m" #define YYCC_COLORHDR_GREEN "\033[32m"
/// @brief The head of ASCII escape code of yellow color.
#define YYCC_COLORHDR_YELLOW "\033[33m" #define YYCC_COLORHDR_YELLOW "\033[33m"
/// @brief The head of ASCII escape code of blue color.
#define YYCC_COLORHDR_BLUE "\033[34m" #define YYCC_COLORHDR_BLUE "\033[34m"
/// @brief The head of ASCII escape code of magenta color.
#define YYCC_COLORHDR_MAGENTA "\033[35m" #define YYCC_COLORHDR_MAGENTA "\033[35m"
/// @brief The head of ASCII escape code of cyan color.
#define YYCC_COLORHDR_CYAN "\033[36m" #define YYCC_COLORHDR_CYAN "\033[36m"
/// @brief The head of ASCII escape code of white color.
#define YYCC_COLORHDR_WHITE "\033[37m" #define YYCC_COLORHDR_WHITE "\033[37m"
/// @brief The head of ASCII escape code of light black color.
#define YYCC_COLORHDR_LIGHT_BLACK "\033[90m" #define YYCC_COLORHDR_LIGHT_BLACK "\033[90m"
/// @brief The head of ASCII escape code of light red color.
#define YYCC_COLORHDR_LIGHT_RED "\033[91m" #define YYCC_COLORHDR_LIGHT_RED "\033[91m"
/// @brief The head of ASCII escape code of light green color.
#define YYCC_COLORHDR_LIGHT_GREEN "\033[92m" #define YYCC_COLORHDR_LIGHT_GREEN "\033[92m"
/// @brief The head of ASCII escape code of light yellow color.
#define YYCC_COLORHDR_LIGHT_YELLOW "\033[93m" #define YYCC_COLORHDR_LIGHT_YELLOW "\033[93m"
/// @brief The head of ASCII escape code of light blue color.
#define YYCC_COLORHDR_LIGHT_BLUE "\033[94m" #define YYCC_COLORHDR_LIGHT_BLUE "\033[94m"
/// @brief The head of ASCII escape code of light magenta color.
#define YYCC_COLORHDR_LIGHT_MAGENTA "\033[95m" #define YYCC_COLORHDR_LIGHT_MAGENTA "\033[95m"
/// @brief The head of ASCII escape code of light cyan color.
#define YYCC_COLORHDR_LIGHT_CYAN "\033[96m" #define YYCC_COLORHDR_LIGHT_CYAN "\033[96m"
/// @brief The head of ASCII escape code of light white color.
#define YYCC_COLORHDR_LIGHT_WHITE "\033[97m" #define YYCC_COLORHDR_LIGHT_WHITE "\033[97m"
/// @brief The tail of ASCII escape code of every color.
#define YYCC_COLORTAIL "\033[0m" #define YYCC_COLORTAIL "\033[0m"
/// @brief The ASCII escape code pair of black color.
#define YYCC_COLOR_BLACK(T) "\033[30m" T "\033[0m" #define YYCC_COLOR_BLACK(T) "\033[30m" T "\033[0m"
/// @brief The ASCII escape code pair of red color.
#define YYCC_COLOR_RED(T) "\033[31m" T "\033[0m" #define YYCC_COLOR_RED(T) "\033[31m" T "\033[0m"
/// @brief The ASCII escape code pair of green color.
#define YYCC_COLOR_GREEN(T) "\033[32m" T "\033[0m" #define YYCC_COLOR_GREEN(T) "\033[32m" T "\033[0m"
/// @brief The ASCII escape code pair of yellow color.
#define YYCC_COLOR_YELLOW(T) "\033[33m" T "\033[0m" #define YYCC_COLOR_YELLOW(T) "\033[33m" T "\033[0m"
/// @brief The ASCII escape code pair of blue color.
#define YYCC_COLOR_BLUE(T) "\033[34m" T "\033[0m" #define YYCC_COLOR_BLUE(T) "\033[34m" T "\033[0m"
/// @brief The ASCII escape code pair of magenta color.
#define YYCC_COLOR_MAGENTA(T) "\033[35m" T "\033[0m" #define YYCC_COLOR_MAGENTA(T) "\033[35m" T "\033[0m"
/// @brief The ASCII escape code pair of cyan color.
#define YYCC_COLOR_CYAN(T) "\033[36m" T "\033[0m" #define YYCC_COLOR_CYAN(T) "\033[36m" T "\033[0m"
/// @brief The ASCII escape code pair of white color.
#define YYCC_COLOR_WHITE(T) "\033[37m" T "\033[0m" #define YYCC_COLOR_WHITE(T) "\033[37m" T "\033[0m"
/// @brief The ASCII escape code pair of light black color.
#define YYCC_COLOR_LIGHT_BLACK(T) "\033[90m" T "\033[0m" #define YYCC_COLOR_LIGHT_BLACK(T) "\033[90m" T "\033[0m"
/// @brief The ASCII escape code pair of light red color.
#define YYCC_COLOR_LIGHT_RED(T) "\033[91m" T "\033[0m" #define YYCC_COLOR_LIGHT_RED(T) "\033[91m" T "\033[0m"
/// @brief The ASCII escape code pair of light green color.
#define YYCC_COLOR_LIGHT_GREEN(T) "\033[92m" T "\033[0m" #define YYCC_COLOR_LIGHT_GREEN(T) "\033[92m" T "\033[0m"
/// @brief The ASCII escape code pair of light yellow color.
#define YYCC_COLOR_LIGHT_YELLOW(T) "\033[93m" T "\033[0m" #define YYCC_COLOR_LIGHT_YELLOW(T) "\033[93m" T "\033[0m"
/// @brief The ASCII escape code pair of light blue color.
#define YYCC_COLOR_LIGHT_BLUE(T) "\033[94m" T "\033[0m" #define YYCC_COLOR_LIGHT_BLUE(T) "\033[94m" T "\033[0m"
/// @brief The ASCII escape code pair of light magenta color.
#define YYCC_COLOR_LIGHT_MAGENTA(T) "\033[95m" T "\033[0m" #define YYCC_COLOR_LIGHT_MAGENTA(T) "\033[95m" T "\033[0m"
/// @brief The ASCII escape code pair of light cyan color.
#define YYCC_COLOR_LIGHT_CYAN(T) "\033[96m" T "\033[0m" #define YYCC_COLOR_LIGHT_CYAN(T) "\033[96m" T "\033[0m"
/// @brief The ASCII escape code pair of light white color.
#define YYCC_COLOR_LIGHT_WHITE(T) "\033[97m" T "\033[0m" #define YYCC_COLOR_LIGHT_WHITE(T) "\033[97m" T "\033[0m"
/** /**
* @brief Enable Windows console color support. * @brief Enable console color support for Windows.
* @details This actually is enable virtual console feature for stdout and stderr. * @details This actually is enable virtual console feature for \c stdout and \c stderr.
* @return True if success, otherwise false. * @return True if success, otherwise false.
* @remarks This function only works on Windows and do nothing on other platforms such as Linux, * @remarks
* This function only works on Windows and do nothing on other platforms such as Linux,
* because we assume all terminals existing on other platform support color feature as default. * because we assume all terminals existing on other platform support color feature as default.
*/ */
bool EnableColorfulConsole(); bool EnableColorfulConsole();
/** /**
* @brief Universal console read function * @brief Reads the next line of UTF8 characters from the standard input stream.
* @return * @return
* The UTF8 encoded string this function read. EOL is excluded. * The next line of UTF8 characters from the input stream.
* Empty string if user just press Enter key or function failed. * Empty string if user just press Enter key or function failed.
* @remarks
* This function is more like C# Console.ReadLine().
* It read user input with UTF8 encoding until reaching EOL.
* \par
* This function also can be used as ordering user press Enter key by
* simply calling this function and ignoring its return value.
*/ */
yycc_u8string ReadLine(); yycc_u8string ReadLine();
/** /**
* @brief Universal console write function with format feature. * @brief
* Writes the text representation of the specified object
* to the standard output stream using the specified format information.
* @param[in] u8_fmt The format string. * @param[in] u8_fmt The format string.
* @param[in] ... The arguments to be formatted. * @param[in] ... The arguments of format string.
*/ */
void Format(const yycc_char8_t* u8_fmt, ...); void Format(const yycc_char8_t* u8_fmt, ...);
/** /**
* @brief Universal console write function with format and auto EOL feature. * @brief
* Writes the text representation of the specified object,
* followed by the current line terminator,
* to the standard output stream using the specified format information.
* @param[in] u8_fmt The format string. * @param[in] u8_fmt The format string.
* @param[in] ... The arguments to be formatted. * @param[in] ... The arguments of format string.
*/ */
void FormatLine(const yycc_char8_t* u8_fmt, ...); void FormatLine(const yycc_char8_t* u8_fmt, ...);
/** /**
* @brief Universal console write function. * @brief Writes the specified string value to the standard output stream.
* @param[in] u8_strl The string to be written. * @param[in] u8_strl The value to write.
*/ */
void Write(const yycc_char8_t* u8_strl); void Write(const yycc_char8_t* u8_strl);
/** /**
* @brief Universal console write function with auto EOL feature. * @brief
* @param[in] u8_strl The string to be written. * Writes the specified string value, followed by the current line terminator,
* to the standard output stream.
* @param[in] u8_strl The value to write.
*/ */
void WriteLine(const yycc_char8_t* u8_strl); void WriteLine(const yycc_char8_t* u8_strl);
/** /**
* @brief Universal console error write function with format and feature. * @brief
* Writes the text representation of the specified object
* to the standard error stream using the specified format information.
* @param[in] u8_fmt The format string. * @param[in] u8_fmt The format string.
* @param[in] ... The arguments to be formatted. * @param[in] ... The arguments of format string.
*/ */
void ErrFormat(const yycc_char8_t* u8_fmt, ...); void ErrFormat(const yycc_char8_t* u8_fmt, ...);
/** /**
* @brief Universal console error write function with format and auto EOL feature. * @brief
* Writes the text representation of the specified object,
* followed by the current line terminator,
* to the standard error stream using the specified format information.
* @param[in] u8_fmt The format string. * @param[in] u8_fmt The format string.
* @param[in] ... The arguments to be formatted. * @param[in] ... The arguments of format string.
*/ */
void ErrFormatLine(const yycc_char8_t* u8_fmt, ...); void ErrFormatLine(const yycc_char8_t* u8_fmt, ...);
/** /**
* @brief Universal console error write function. * @brief Writes the specified string value to the standard error stream.
* @param[in] u8_strl The string to be written. * @param[in] u8_strl The value to write.
*/ */
void ErrWrite(const yycc_char8_t* u8_strl); void ErrWrite(const yycc_char8_t* u8_strl);
/** /**
* @brief Universal console error write function with auto EOL feature. * @brief
* @param[in] u8_strl The string to be written. * Writes the specified string value, followed by the current line terminator,
* to the standard error stream.
* @param[in] u8_strl The value to write.
*/ */
void ErrWriteLine(const yycc_char8_t* u8_strl); void ErrWriteLine(const yycc_char8_t* u8_strl);

View File

@ -176,7 +176,7 @@ namespace YYCC::DialogHelper {
}; };
/** /**
* @brief The class represent the file dialog. * @brief The class representing the file dialog.
* @details * @details
* This class is served for programming using to describe every aspectes of the dialog. * This class is served for programming using to describe every aspectes of the dialog.
* For how to use this struct, see \ref dialog_helper. * For how to use this struct, see \ref dialog_helper.

View File

@ -10,7 +10,7 @@
#endif #endif
/** /**
* @brief The helper for all encoding aspects. * @brief The helper for all encoding stuff.
* @details * @details
* For more infomations about how to use the functions provided by this namespace, * For more infomations about how to use the functions provided by this namespace,
* please see \ref library_encoding and \ref encoding_helper. * please see \ref library_encoding and \ref encoding_helper.
@ -19,7 +19,7 @@ namespace YYCC::EncodingHelper {
#define _YYCC_U8(strl) u8 ## strl ///< The assistant macro for YYCC_U8. #define _YYCC_U8(strl) u8 ## strl ///< The assistant macro for YYCC_U8.
#define YYCC_U8(strl) (reinterpret_cast<const ::YYCC::yycc_char8_t*>(_YYCC_U8(strl))) ///< The macro for creating UTF8 string literal. See \ref library_encoding. #define YYCC_U8(strl) (reinterpret_cast<const ::YYCC::yycc_char8_t*>(_YYCC_U8(strl))) ///< The macro for creating UTF8 string literal. See \ref library_encoding.
#define YYCC_U8_CHAR(chr) (static_cast<YYCC::yycc_char8_t>(chr)) ///< The macro for casting normal char into YYCC UTF8 char type. #define YYCC_U8_CHAR(chr) (static_cast<YYCC::yycc_char8_t>(chr)) ///< The macro for casting ordinary char type into YYCC UTF8 char type.
const yycc_char8_t* ToUTF8(const char* src); const yycc_char8_t* ToUTF8(const char* src);
yycc_char8_t* ToUTF8(char* src); yycc_char8_t* ToUTF8(char* src);

View File

@ -6,10 +6,7 @@
* @brief Windows specific unhandled exception processor. * @brief Windows specific unhandled exception processor.
* @details * @details
* This namespace is Windows specific. On other platforms, the whole namespace is unavailable. * This namespace is Windows specific. On other platforms, the whole namespace is unavailable.
* * For how to utilize this namespace, please see \ref exception_helper.
* This namespace allow user register unhandled exception handler on Windows
* to output error log into \c stderr and log file, and generate coredump if possible.
* This is useful for bug tracing on Windows, especially most Windows user are naive and don't know how to report bug.
* *
*/ */
namespace YYCC::ExceptionHelper { namespace YYCC::ExceptionHelper {
@ -20,9 +17,9 @@ namespace YYCC::ExceptionHelper {
* This function will set an internal function as unhandled exception handler on Windows. * This function will set an internal function as unhandled exception handler on Windows.
* *
* When unhandled exception raised, * When unhandled exception raised,
* That internal function will output error stacktrace in standard output * That internal function will output error stacktrace in standard output,
* and log file (located in temp folder), and also generate a dump file * and generate log file and dump file in \c \%APPDATA\%/CrashDumps folder if it is possible.
* in temp folder (for convenient debugging of developer when reporting bugs) if it can. * (for convenient debugging of developer when reporting bugs.)
* *
* This function usually is called at the start of program. * This function usually is called at the start of program.
*/ */
@ -33,7 +30,7 @@ namespace YYCC::ExceptionHelper {
* The reverse operation of Register(). * The reverse operation of Register().
* *
* This function and Register() should always be used as a pair. * This function and Register() should always be used as a pair.
* You must call this function if you have called Register() before. * You must call this function to release reources if you have called Register().
* *
* This function usually is called at the end of program. * This function usually is called at the end of program.
*/ */

View File

@ -38,6 +38,28 @@ namespace YYCC {
using yycc_u8string = std::basic_string<yycc_char8_t>; using yycc_u8string = std::basic_string<yycc_char8_t>;
using yycc_u8string_view = std::basic_string_view<yycc_char8_t>; using yycc_u8string_view = std::basic_string_view<yycc_char8_t>;
#endif #endif
/**
\typedef yycc_char8_t
\brief YYCC UTF8 char type.
\details
This char type is an alias to \c std::char8_t if your current C++ standard support it.
Otherwise it is defined as <TT>unsigned char</TT> as C++ 20 stdandard does.
*/
/**
\typedef yycc_u8string
\brief YYCC UTF8 string container type.
\details
This type is defined as \c std::basic_string<yycc_char8_t>.
It is equal to \c std::u8string if your current C++ standard support it.
*/
/**
\typedef yycc_u8string_view
\brief YYCC UTF8 string view type.
\details
This type is defined as \c std::basic_string_view<yycc_char8_t>.
It is equal to \c std::u8string_view if your current C++ standard support it.
*/
} }