Skip to content

Commit 4486637

Browse files
add C++ class for output
1 parent 9285715 commit 4486637

File tree

1 file changed

+70
-0
lines changed

1 file changed

+70
-0
lines changed

code/logic/fossil/io/output.h

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,76 @@ void fossil_io_putchar_color(char c, const char *color);
7676

7777
#ifdef __cplusplus
7878
}
79+
/**
80+
* C++ wrapper for the output functions.
81+
*/
82+
namespace fossil {
83+
/**
84+
* Namespace for input/output operations.
85+
*/
86+
namespace io {
87+
/**
88+
* Class for output operations.
89+
*/
90+
class Output {
91+
public:
92+
/**
93+
* Prints a string to the output.
94+
*
95+
* @param str The string to be printed.
96+
*/
97+
static void puts(const char *str) {
98+
fossil_io_puts(str);
99+
}
100+
101+
/**
102+
* Prints a formatted string to the output.
103+
*
104+
* @param format The format string.
105+
* @param ... The additional arguments to be formatted.
106+
*/
107+
static void printf(const char *format, ...) {
108+
va_list args;
109+
va_start(args, format);
110+
fossil_io_printf(format, args);
111+
va_end(args);
112+
}
113+
114+
/**
115+
* Prints a string to the output with a specified color.
116+
*
117+
* @param color The color code to be applied.
118+
* @param str The string to be printed.
119+
*/
120+
static void print_color(const char *color, const char *format, ...) {
121+
va_list args;
122+
va_start(args, format);
123+
fossil_io_print_color(color, format, args);
124+
va_end(args);
125+
}
126+
127+
/**
128+
* Prints a character to the output.
129+
*
130+
* @param c The character to be printed.
131+
*/
132+
static void putchar(char c) {
133+
fossil_io_putchar(c);
134+
}
135+
136+
/**
137+
* Prints a character to the output with a specified color.
138+
*
139+
* @param c The character to be printed.
140+
* @param color The color code to be applied.
141+
*/
142+
static void putchar_color(char c, const char *color) {
143+
fossil_io_putchar_color(c, color);
144+
}
145+
}
146+
}
147+
}
148+
79149
#endif
80150

81151
#endif /* FOSSIL_IO_FRAMEWORK_H */

0 commit comments

Comments
 (0)