Code

Fixed const/non-const mismatch loop.
[inkscape.git] / src / util / format.h
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.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        // needed since G_GNUC_PRINTF can only be used on a declaration
31        ptr_shared<char> format(char const *format, ...) G_GNUC_PRINTF(1,2);
32 inline ptr_shared<char> format(char const *format, ...) {
33     va_list args;
35     va_start(args, format);
36     ptr_shared<char> result=vformat(format, args);
37     va_end(args);
39     return result;
40 }
42 }
44 }
46 #endif
47 /*
48   Local Variables:
49   mode:c++
50   c-file-style:"stroustrup"
51   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
52   indent-tabs-mode:nil
53   fill-column:99
54   End:
55 */
56 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :