file
IO.hCnx I/O brings human readable formatted I/O, similar to C++'s std::format
and fmtlib
, and Rust's std::format, to C.
MIT License
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Functions
-
void print_(restrict const_
cstring format_string, CnxAllocator allocator, usize num_args, ...) - Formats the given arguments into the specified format string then prints it to
stdout
-
void eprint_(restrict const_
cstring format_string, CnxAllocator allocator, usize num_args, ...) - Formats the given arguments into the specified format string then prints it to
Cnxerr
-
void fprint_(FILE* file,
restrict const_
cstring format_string, CnxAllocator allocator, usize num_args, ...) cnx_disable_if(!file - Formats the given arguments into the specified format string then prints it to the given file.
-
void println_(restrict const_
cstring format_string, CnxAllocator allocator, usize num_args, ...) - Formats the given arguments into the specified format string then prints it to
stdout
, followed by a newline. -
void eprintln_(restrict const_
cstring format_string, CnxAllocator allocator, usize num_args, ...) - Formats the given arguments into the specified format string then prints it to
stderr
, followed by a newline. -
void fprintln_(FILE* file,
restrict const_
cstring format_string, CnxAllocator allocator, usize num_args, ...) cnx_disable_if(!file - Formats the given arguments into the specified format string then prints it to the given file, followed by a newline.
Defines
- #define CNX_IO
- Declarations and definitions for Standard I/O.
- #define fprint_with_allocator(file_ptr, format_string, allocator, ...)
- Formats the given arguments into the specified format string then prints it to the given file.
- #define fprint(file_ptr, format_string, ...)
- Formats the given arguments into the specified format string then prints it to the given file.
- #define print_with_allocator(format_string, allocator, ...)
- Formats the given arguments into the specified format string then prints it to
stdout
- #define print(format_string, ...)
- Formats the given arguments into the specified format string then prints it to
stdout
- #define eprint_with_allocator(format_string, allocator, ...)
- Formats the given arguments into the specified format string then prints it to
stderr
- #define eprint(format_string, ...)
- Formats the given arguments into the specified format string then prints it to
stderr
- #define fprintln_with_allocator(file_ptr, format_string, allocator, ...)
- Formats the given arguments into the specified format string then prints it to the given file, followed by a newline.
- #define fprintln(file_ptr, format_string, ...)
- Formats the given arguments into the specified format string then prints it to the given file, followed by a newline.
- #define println_with_allocator(format_string, allocator, ...)
- Formats the given arguments into the specified format string then prints it to
stdout
, followed by a newline. - #define println(format_string, ...)
- Formats the given arguments into the specified format string then prints it to
stdout
, followed by a newline. - #define eprintln_with_allocator(format_string, allocator, ...)
- Formats the given arguments into the specified format string then prints it to
stderr
, followed by a newline. - #define eprintln(format_string, ...)
- Formats the given arguments into the specified format string then prints it to
stderr
, followed by a newline.
Function documentation
void print_(restrict const_ cstring format_string,
CnxAllocator allocator,
usize num_args,
...)
Formats the given arguments into the specified format string then prints it to stdout
Parameters | |
---|---|
format_string | - The format string specifying how text and arguments should be formatted |
allocator | - The allocator to allocate the formatted string with |
num_args | - The number of args in the parameter pack |
void eprint_(restrict const_ cstring format_string,
CnxAllocator allocator,
usize num_args,
...)
Formats the given arguments into the specified format string then prints it to Cnxerr
Parameters | |
---|---|
format_string | - The format string specifying how text and arguments should be formatted |
allocator | - The allocator to allocate the formatted string with |
num_args | - The number of args in the parameter pack |
void fprint_(FILE* file,
restrict const_ cstring format_string,
CnxAllocator allocator,
usize num_args,
...) cnx_disable_if(!file
Formats the given arguments into the specified format string then prints it to the given file.
Parameters | |
---|---|
file | - The file to print the formatted string to |
format_string | - The format string specifying how text and arguments should be formatted |
allocator | - The allocator to allocate the formatted string with |
num_args | - The number of args in the parameter pack |
void println_(restrict const_ cstring format_string,
CnxAllocator allocator,
usize num_args,
...)
Formats the given arguments into the specified format string then prints it to stdout
, followed by a newline.
Parameters | |
---|---|
format_string | - The format string specifying how text and arguments should be formatted |
allocator | - The allocator to allocate the formatted string with |
num_args | - The number of args in the parameter pack |
void eprintln_(restrict const_ cstring format_string,
CnxAllocator allocator,
usize num_args,
...)
Formats the given arguments into the specified format string then prints it to stderr
, followed by a newline.
Parameters | |
---|---|
format_string | - The format string specifying how text and arguments should be formatted |
allocator | - The allocator to allocate the formatted string with |
num_args | - The number of args in the parameter pack |
void fprintln_(FILE* file,
restrict const_ cstring format_string,
CnxAllocator allocator,
usize num_args,
...) cnx_disable_if(!file
Formats the given arguments into the specified format string then prints it to the given file, followed by a newline.
Parameters | |
---|---|
file | - The file to print the formatted string to |
format_string | - The format string specifying how text and arguments should be formatted |
allocator | - The allocator to allocate the formatted string with |
num_args | - The number of args in the parameter pack |
Define documentation
#define fprintln_with_allocator(file_ptr, format_string, allocator, ...)
Formats the given arguments into the specified format string then prints it to the given file, followed by a newline.
Parameters | |
---|---|
file_ptr | - The file to print the formatted string to |
format_string | - The format string specifying how text and arguments should be formatted |
allocator | - The allocator to allocate the formatted string with |
... | - The parameter pack of arguments to format |
Formats the arguments according to the given format string, allocating the output string and any intermediaries with the given allocator. Requires that the number of specifiers in the format string matches the number of arguments in the parameter pack and that all arguments in the parameter pack have an accessible automatic conversion to CnxFormat
via CNX_CnxFormat
already.