Add header for PBD::to_string/string_to() specialisations for libardour types
[ardour.git] / libs / ardour / ardour / types_convert.h
1 /*
2     Copyright (C) 2015 Tim Mayberry
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
15     along with this program; if not, write to the Free Software
16     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
18 */
19
20 #ifndef ARDOUR_TYPES_CONVERT_H
21 #define ARDOUR_TYPES_CONVERT_H
22
23 #include "pbd/enum_convert.h"
24
25 #include "ardour/types.h"
26 #include "ardour/data_type.h"
27 #include "ardour/mode.h"
28
29 namespace PBD {
30
31 DEFINE_ENUM_CONVERT(Timecode::TimecodeFormat)
32
33 DEFINE_ENUM_CONVERT(ARDOUR::AnyTime::Type)
34 DEFINE_ENUM_CONVERT(ARDOUR::SampleFormat)
35 DEFINE_ENUM_CONVERT(ARDOUR::HeaderFormat)
36 DEFINE_ENUM_CONVERT(ARDOUR::AutoConnectOption)
37 DEFINE_ENUM_CONVERT(ARDOUR::TracksAutoNamingRule)
38 DEFINE_ENUM_CONVERT(ARDOUR::TrackMode)
39 DEFINE_ENUM_CONVERT(ARDOUR::EditMode)
40 DEFINE_ENUM_CONVERT(ARDOUR::MonitorModel)
41 DEFINE_ENUM_CONVERT(ARDOUR::AFLPosition)
42 DEFINE_ENUM_CONVERT(ARDOUR::PFLPosition)
43 DEFINE_ENUM_CONVERT(ARDOUR::ListenPosition)
44 DEFINE_ENUM_CONVERT(ARDOUR::LayerModel)
45 DEFINE_ENUM_CONVERT(ARDOUR::InsertMergePolicy)
46 DEFINE_ENUM_CONVERT(ARDOUR::SyncSource)
47 DEFINE_ENUM_CONVERT(ARDOUR::ShuttleBehaviour)
48 DEFINE_ENUM_CONVERT(ARDOUR::ShuttleUnits)
49 DEFINE_ENUM_CONVERT(ARDOUR::DenormalModel)
50 DEFINE_ENUM_CONVERT(ARDOUR::PositionLockStyle)
51 DEFINE_ENUM_CONVERT(ARDOUR::FadeShape)
52 DEFINE_ENUM_CONVERT(ARDOUR::RegionSelectionAfterSplit)
53 DEFINE_ENUM_CONVERT(ARDOUR::BufferingPreset)
54 DEFINE_ENUM_CONVERT(ARDOUR::AutoReturnTarget)
55 DEFINE_ENUM_CONVERT(ARDOUR::MeterType)
56 DEFINE_ENUM_CONVERT(ARDOUR::MeterPoint)
57 DEFINE_ENUM_CONVERT(ARDOUR::NoteMode)
58 DEFINE_ENUM_CONVERT(ARDOUR::ChannelMode)
59 DEFINE_ENUM_CONVERT(ARDOUR::LocaleMode)
60 DEFINE_ENUM_CONVERT(ARDOUR::MonitorChoice)
61
62 DEFINE_ENUM_CONVERT(ARDOUR::AlignStyle)
63 DEFINE_ENUM_CONVERT(ARDOUR::AlignChoice)
64
65 DEFINE_ENUM_CONVERT(ARDOUR::WaveformScale)
66 DEFINE_ENUM_CONVERT(ARDOUR::WaveformShape)
67 DEFINE_ENUM_CONVERT(ARDOUR::VUMeterStandard)
68 DEFINE_ENUM_CONVERT(ARDOUR::MeterLineUp)
69
70 DEFINE_ENUM_CONVERT(ARDOUR::MidiPortFlags)
71
72 DEFINE_ENUM_CONVERT(MusicalMode::Type)
73
74 template <>
75 inline bool to_string (ARDOUR::AutoState val, std::string& str)
76 {
77         str = ARDOUR::auto_state_to_string (val);
78         return true;
79 }
80
81 template <>
82 inline bool string_to (const std::string& str, ARDOUR::AutoState& as)
83 {
84         as = ARDOUR::string_to_auto_state (str);
85         return true;
86 }
87
88 template <>
89 inline bool to_string (ARDOUR::AutoStyle val, std::string& str)
90 {
91         str = ARDOUR::auto_style_to_string (val);
92         return true;
93 }
94
95 template <>
96 inline bool string_to (const std::string& str, ARDOUR::AutoStyle& as)
97 {
98         as = ARDOUR::string_to_auto_style (str);
99         return true;
100 }
101
102 template <>
103 inline bool to_string (ARDOUR::DataType val, std::string& str)
104 {
105         str = val.to_string();
106         return true;
107 }
108
109 template <>
110 inline bool string_to (const std::string& str, ARDOUR::DataType& dt)
111 {
112         dt = ARDOUR::DataType(str);
113         return true;
114 }
115
116 } // namespace PBD
117
118 #endif // ARDOUR_TYPES_CONVERT_H