2009-12-03 Jeffrey Stedfast <fejj@novell.com>
[moon.git] / src / thickness.cpp
blob28cb84549ac26010ce3246bfb1980948d9eca482
1 /*
2 * thickness.cpp: Thickness parsing
4 * Contact:
5 * Moonlight List (moonlight-list@lists.ximian.com)
7 * Copyright 2007 Novell, Inc. (http://www.novell.com)
9 * See the LICENSE file included with the distribution for details.
13 #include <config.h>
14 #include <string.h>
15 #include <stdlib.h>
16 #include <math.h>
18 #include "utils.h"
19 #include "thickness.h"
21 bool
22 Thickness::FromStr (const char *str, Thickness *thickness)
24 GArray *values = double_garray_from_str (str, 0);
25 bool rv = true;
27 switch (values->len) {
28 case 1:
29 *thickness = Thickness (g_array_index (values, double, 0));
30 break;
31 case 2:
32 *thickness = Thickness (g_array_index (values, double, 0),
33 g_array_index (values, double, 1));
34 break;
35 case 4:
36 *thickness = Thickness (g_array_index (values, double, 0),
37 g_array_index (values, double, 1),
38 g_array_index (values, double, 2),
39 g_array_index (values, double, 3));
40 break;
41 default:
42 g_warning ("Thickness specified with %d values, '%s'.", values->len, str);
43 rv = false;
44 break;
47 if (values)
48 g_array_free (values, TRUE);
49 return rv;