mirror of
https://github.com/subsurface/subsurface.git
synced 2024-12-12 03:51:29 +00:00
8b51ff7ded
We had locale aware formatting functions that generated QStrings. Create an alternative that creates std::string, since we want that in the core. This commit is unfortunate for two reasons: - The function is called "casprintf()" for analogy with the QString version. However, the non locale aware function is called "format_string_std()" for analogy with "format_string()". Ultimately these names should be unified. Probably, once there are no membuffer users left. - This does UTF-16->UTF-8->UTF-16 roundtrips. The core formatting functions should render UTF-8 and only convert to UTF-16, in the UI layer. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
30 lines
808 B
C++
30 lines
808 B
C++
#ifndef FORMAT_H
|
|
#define FORMAT_H
|
|
|
|
#ifdef __GNUC__
|
|
#define __printf(x, y) __attribute__((__format__(__printf__, x, y)))
|
|
#else
|
|
#define __printf(x, y)
|
|
#endif
|
|
|
|
#ifdef __cplusplus
|
|
#include <QString>
|
|
__printf(1, 2) QString qasprintf_loc(const char *cformat, ...);
|
|
__printf(1, 0) QString vqasprintf_loc(const char *cformat, va_list ap);
|
|
__printf(1, 2) std::string casprintf_loc(const char *cformat, ...);
|
|
#endif
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
__printf(3, 4) int snprintf_loc(char *dst, size_t size, const char *cformat, ...);
|
|
__printf(3, 0) int vsnprintf_loc(char *dst, size_t size, const char *cformat, va_list ap);
|
|
__printf(2, 3) int asprintf_loc(char **dst, const char *cformat, ...);
|
|
__printf(2, 0) int vasprintf_loc(char **dst, const char *cformat, va_list ap);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif
|