r42@gandalf: fugalh | 2006-06-07 17:08:39 -0600
[ardour.git] / libs / pbd3 / pbd / datum.h
1 /*
2     Copyright (C) 1998-99 Paul Barton-Davis 
3     This program is free software; you can redistribute it and/or modify
4     it under the terms of the GNU General Public License as published by
5     the Free Software Foundation; either version 2 of the License, or
6     (at your option) any later version.
7
8     This program is distributed in the hope that it will be useful,
9     but WITHOUT ANY WARRANTY; without even the implied warranty of
10     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11     GNU General Public License for more details.
12
13     You should have received a copy of the GNU General Public License
14     along with this program; if not, write to the Free Software
15     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
16
17     $Id$
18 */
19
20 #ifndef __qm_datum_h__
21 #define __qm_datum_h__
22
23 /* A basic data type used whenever we want to represent
24    something that might be a string or a number.
25 */
26
27 struct Datum {
28         enum Type {
29                 String,
30                 Numeric,
31         };
32         Type type;
33         union {
34                 const char *str;
35                 float n;
36         };
37
38         Datum &operator=(float val) {
39                 type = Numeric;
40                 n = val;
41                 return *this;
42         }
43
44         Datum &operator=(int val) {
45                 type = Numeric;
46                 n=(float) val;
47                 return *this;
48         }
49
50         Datum &operator=(const char *val) {
51                 type = String;
52                 str = val;
53                 return *this;
54         }
55 };
56
57 #endif // __qm_datum_h__