Code

setting of attributes and default values for feColorMatrix.
[inkscape.git] / src / helper-fns.h
1 #ifndef SEEN_HELPER_FNS_H
2 #define SEEN_HELPER_FNS_H
3 /** \file
4  * 
5  * Some helper functions
6  * 
7  * Authors:
8  *   Felipe CorrĂȘa da Silva Sanches <felipe.sanches@gmail.com>
9  * 
10  *
11  * Copyright (C) 2006 Hugo Rodrigues
12  *
13  * Released under GNU GPL, read the file 'COPYING' for more information
14  */
16 static double
17 helperfns_read_number(gchar const *value) {
18     if (!value) return 0;
19     char *end;
20     double ret = g_ascii_strtod(value, &end);
21     if (*end) {
22         g_warning("Unable to convert \"%s\" to number", value);
23         // We could leave this out, too. If strtod can't convert
24         // anything, it will return zero.
25         ret = 0;
26     }
27     return ret;
28 }
30 static bool helperfns_read_bool(gchar const *value, bool default_value){
31     if (!value) return default_value;
32     switch(value[0]){
33         case 't':
34             if (strncmp(value, "true", 4) == 0) return true;
35             break;
36         case 'f':
37             if (strncmp(value, "false", 5) == 0) return false;
38             break;
39     }
40     return default_value;
41 }
43 static std::vector<gdouble> helperfns_read_vector(const gchar* value, int size){
44         std::vector<gdouble> v(size, (gdouble) 0);
45         int i;
46         gchar** values = g_strsplit(value , " ", size);
47         for (i=0;i<size;i++)
48                 v[i] = g_ascii_strtod(values[i], NULL);
49         return v;
50 }
52 #endif /* !SEEN_HELPER_FNS_H */
54 /*
55   Local Variables:
56   mode:c++
57   c-file-style:"stroustrup"
58   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
59   indent-tabs-mode:nil
60   fill-column:99
61   End:
62 */
63 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :