Debian Codegraph @

include/ruby/internal/encoding/sprintf.h

raw
1 #ifndef RUBY_INTERNAL_ENCODING_SPRINTF_H /*-*-C++-*-vi:se ft=cpp:*/
2 #define RUBY_INTERNAL_ENCODING_SPRINTF_H
3 /**
4 * @file
5 * @author Ruby developers <[email protected]>
6 * @copyright This file is a part of the programming language Ruby.
7 * Permission is hereby granted, to either redistribute and/or
8 * modify this file, provided that the conditions mentioned in the
9 * file COPYING are met. Consult the file for details.
10 * @warning Symbols prefixed with either `RBIMPL` or `rbimpl` are
11 * implementation details. Don't take them as canon. They could
12 * rapidly appear then vanish. The name (path) of this header file
13 * is also an implementation detail. Do not expect it to persist
14 * at the place it is now. Developers are free to move it anywhere
15 * anytime at will.
16 * @note To ruby-core: remember that this header can be possibly
17 * recursively included from extension libraries written in C++.
18 * Do not expect for instance `__VA_ARGS__` is always available.
19 * We assume C99 for ruby itself but we don't assume languages of
20 * extension libraries. They could be written in C++98.
21 * @brief Routines to manipulate encodings of symbols.
22 */
23 #include "ruby/internal/config.h"
24 #include <stdarg.h>
25 #include "ruby/internal/attr/format.h"
26 #include "ruby/internal/attr/nonnull.h"
27 #include "ruby/internal/attr/noreturn.h"
28 #include "ruby/internal/dllexport.h"
29 #include "ruby/internal/encoding/encoding.h"
30 #include "ruby/internal/value.h"
31
32 RBIMPL_SYMBOL_EXPORT_BEGIN()
33 RBIMPL_ATTR_NONNULL((2))
34 RBIMPL_ATTR_FORMAT(RBIMPL_PRINTF_FORMAT, 2, 3)
35 /**
36 * Identical to rb_sprintf(), except it additionally takes an encoding. The
37 * passed encoding rules both the incoming format specifier and the resulting
38 * string.
39 *
40 * @param[in] enc Encoding of `fmt`.
41 * @param[in] fmt A `printf`-like format specifier.
42 * @param[in] ... Variadic number of contents to format.
43 * @return A rendered new instance of ::rb_cString, of `enc` encoding.
44 */
45 VALUE rb_enc_sprintf(rb_encoding *enc, const char *fmt, ...);
46
47 RBIMPL_ATTR_NONNULL((2))
48 RBIMPL_ATTR_FORMAT(RBIMPL_PRINTF_FORMAT, 2, 0)
49 /**
50 * Identical to rb_enc_sprintf(), except it takes a `va_list` instead of
51 * variadic arguments. It can also be seen as a routine identical to
52 * rb_vsprintf(), except it additionally takes an encoding.
53 *
54 * @param[in] enc Encoding of `fmt`.
55 * @param[in] fmt A `printf`-like format specifier.
56 * @param[in] ap Contents to format.
57 * @return A rendered new instance of ::rb_cString, of `enc` encoding.
58 */
59 VALUE rb_enc_vsprintf(rb_encoding *enc, const char *fmt, va_list ap);
60
61 RBIMPL_ATTR_NORETURN()
62 RBIMPL_ATTR_NONNULL((3))
63 RBIMPL_ATTR_FORMAT(RBIMPL_PRINTF_FORMAT, 3, 4)
64 /**
65 * Identical to rb_raise(), except it additionally takes an encoding.
66 *
67 * @param[in] enc Encoding of the generating exception.
68 * @param[in] exc A subclass of ::rb_eException.
69 * @param[in] fmt Format specifier string compatible with rb_sprintf().
70 * @param[in] ... Contents of the message.
71 * @exception exc The specified exception.
72 * @note It never returns.
73 */
74 void rb_enc_raise(rb_encoding *enc, VALUE exc, const char *fmt, ...);
75
76 RBIMPL_SYMBOL_EXPORT_END()
77
78 #endif /* RUBY_INTERNAL_ENCODING_SPRINTF_H */