1 /*
2 * Inkscape::Util::format - g_strdup_printf wrapper producing shared strings
3 *
4 * Authors:
5 * MenTaLguY <mental@rydia.net>
6 *
7 * Copyright (C) 2006 MenTaLguY
8 *
9 * Released under GNU GPL, read the file 'COPYING' for more information
10 */
12 #ifndef SEEN_INKSCAPE_UTIL_FORMAT_H
13 #define SEEN_INKSCAPE_UTIL_FORMAT_H
15 #include <stdarg.h>
16 #include <glib/gstrfuncs.h>
17 #include "util/share.h"
19 namespace Inkscape {
21 namespace Util {
23 inline ptr_shared<char> vformat(char const *format, va_list args) {
24 char *temp=g_strdup_vprintf(format, args);
25 ptr_shared<char> result=share_string(temp);
26 g_free(temp);
27 return result;
28 }
30 inline ptr_shared<char> format(char const *format, ...) {
31 va_list args;
33 va_start(args, format);
34 ptr_shared<char> result=vformat(format, args);
35 va_end(args);
37 return result;
38 }
40 }
42 }
44 #endif
45 /*
46 Local Variables:
47 mode:c++
48 c-file-style:"stroustrup"
49 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
50 indent-tabs-mode:nil
51 fill-column:99
52 End:
53 */
54 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :