1 /* Aravis - Digital camera library
2 *
3 * Copyright © 2009-2010 Emmanuel Pacaud
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General
16 * Public License along with this library; if not, write to the
17 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
19 *
20 * Author: Emmanuel Pacaud <emmanuel@gnome.org>
21 */
22
23 #include <arvenums.h>
24
25 static unsigned int
_from_string(const char * string,const char ** strings,unsigned int n_strings)26 _from_string (const char *string, const char **strings, unsigned int n_strings)
27 {
28 unsigned int i;
29
30 if (string == NULL)
31 return 0;
32
33 for (i = 0; i < n_strings; i++)
34 if (g_strcmp0 (string, strings[i]) == 0)
35 return i;
36
37 return 0;
38 }
39
40 static const char *arv_auto_strings[] = {
41 "Off",
42 "Once",
43 "Continuous"
44 };
45
46 const char *
arv_auto_to_string(ArvAuto value)47 arv_auto_to_string (ArvAuto value)
48 {
49 return arv_auto_strings[CLAMP (value, 0, ARV_AUTO_CONTINUOUS)];
50 }
51
52 ArvAuto
arv_auto_from_string(const char * string)53 arv_auto_from_string (const char *string)
54 {
55 return _from_string (string, arv_auto_strings,
56 G_N_ELEMENTS (arv_auto_strings));
57 }
58
59 static const char *arv_acquisition_mode_strings[] = {
60 "Continuous",
61 "SingleFrame",
62 "MultiFrame"
63 };
64
65 const char *
arv_acquisition_mode_to_string(ArvAcquisitionMode value)66 arv_acquisition_mode_to_string (ArvAcquisitionMode value)
67 {
68 return arv_acquisition_mode_strings[CLAMP (value, 0, ARV_ACQUISITION_MODE_MULTI_FRAME)];
69 }
70
71 ArvAcquisitionMode
arv_acquisition_mode_from_string(const char * string)72 arv_acquisition_mode_from_string (const char *string)
73 {
74 return _from_string (string, arv_acquisition_mode_strings,
75 G_N_ELEMENTS (arv_acquisition_mode_strings));
76 }
77