Ardour  8.7-14-g57a6773833
typed_value.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2020 Luciano Iam <oss@lucianoiam.com>
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License along
15  * with this program; if not, write to the Free Software Foundation, Inc.,
16  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17  */
18 
19 #ifndef _ardour_surface_websockets_typed_value_h_
20 #define _ardour_surface_websockets_typed_value_h_
21 
22 #include <string>
23 
24 namespace ArdourSurface {
25 
27 {
28 public:
29  enum Type {
32  Int,
34  String
35  };
36 
38  TypedValue (bool);
39  TypedValue (int);
40  TypedValue (double);
41  TypedValue (std::string);
42 
43  bool empty () const
44  {
45  return _type == Empty;
46  };
47  Type type () const
48  {
49  return _type;
50  };
51 
52  operator bool () const;
53  operator int () const;
54  operator double () const;
55  operator std::string () const;
56 
57  bool operator== (const TypedValue& other) const;
58  bool operator!= (const TypedValue& other) const;
59 
60  std::string debug_str () const;
61 
62 private:
64  bool _b;
65  int _i;
66  double _d;
67  std::string _s;
68 };
69 
70 } // namespace ArdourSurface
71 
72 #endif // _ardour_surface_websockets_typed_value_h_
std::string debug_str() const
bool operator==(const TypedValue &other) const
bool operator!=(const TypedValue &other) const