summaryrefslogtreecommitdiff
path: root/libs/ardour/ardour/types_convert.h
diff options
context:
space:
mode:
authorTim Mayberry <mojofunk@gmail.com>2016-09-02 10:08:43 +1000
committerTim Mayberry <mojofunk@gmail.com>2017-04-19 09:36:42 +1000
commit911e2af0181ecc4d937cbfd9a926b1d527e7ae42 (patch)
treee479dcde950979c515591ac0c95fdd00c7e81eef /libs/ardour/ardour/types_convert.h
parent95b4fd64dd9cd033cfbb22048cad591503d390cc (diff)
Add header for PBD::to_string/string_to() specialisations for libardour types
Add PBD::to_/string_to specializations for ARDOUR::DataType These could go into the data_type.h header but they don't really need to and it means that ardour/types_convert.h can just be included by source files that need to do type<=>string conversion. A potential problem with this is that if all the specializations are contained in a single header then any class that requires inclusion of that header to do serialization will be recompiled each time types_convert.h is changed. I'm not going to worry about it at this stage, it can always be broken up or improved upon later.
Diffstat (limited to 'libs/ardour/ardour/types_convert.h')
-rw-r--r--libs/ardour/ardour/types_convert.h118
1 files changed, 118 insertions, 0 deletions
diff --git a/libs/ardour/ardour/types_convert.h b/libs/ardour/ardour/types_convert.h
new file mode 100644
index 0000000000..dd47eb46f0
--- /dev/null
+++ b/libs/ardour/ardour/types_convert.h
@@ -0,0 +1,118 @@
+/*
+ Copyright (C) 2015 Tim Mayberry
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+*/
+
+#ifndef ARDOUR_TYPES_CONVERT_H
+#define ARDOUR_TYPES_CONVERT_H
+
+#include "pbd/enum_convert.h"
+
+#include "ardour/types.h"
+#include "ardour/data_type.h"
+#include "ardour/mode.h"
+
+namespace PBD {
+
+DEFINE_ENUM_CONVERT(Timecode::TimecodeFormat)
+
+DEFINE_ENUM_CONVERT(ARDOUR::AnyTime::Type)
+DEFINE_ENUM_CONVERT(ARDOUR::SampleFormat)
+DEFINE_ENUM_CONVERT(ARDOUR::HeaderFormat)
+DEFINE_ENUM_CONVERT(ARDOUR::AutoConnectOption)
+DEFINE_ENUM_CONVERT(ARDOUR::TracksAutoNamingRule)
+DEFINE_ENUM_CONVERT(ARDOUR::TrackMode)
+DEFINE_ENUM_CONVERT(ARDOUR::EditMode)
+DEFINE_ENUM_CONVERT(ARDOUR::MonitorModel)
+DEFINE_ENUM_CONVERT(ARDOUR::AFLPosition)
+DEFINE_ENUM_CONVERT(ARDOUR::PFLPosition)
+DEFINE_ENUM_CONVERT(ARDOUR::ListenPosition)
+DEFINE_ENUM_CONVERT(ARDOUR::LayerModel)
+DEFINE_ENUM_CONVERT(ARDOUR::InsertMergePolicy)
+DEFINE_ENUM_CONVERT(ARDOUR::SyncSource)
+DEFINE_ENUM_CONVERT(ARDOUR::ShuttleBehaviour)
+DEFINE_ENUM_CONVERT(ARDOUR::ShuttleUnits)
+DEFINE_ENUM_CONVERT(ARDOUR::DenormalModel)
+DEFINE_ENUM_CONVERT(ARDOUR::PositionLockStyle)
+DEFINE_ENUM_CONVERT(ARDOUR::FadeShape)
+DEFINE_ENUM_CONVERT(ARDOUR::RegionSelectionAfterSplit)
+DEFINE_ENUM_CONVERT(ARDOUR::BufferingPreset)
+DEFINE_ENUM_CONVERT(ARDOUR::AutoReturnTarget)
+DEFINE_ENUM_CONVERT(ARDOUR::MeterType)
+DEFINE_ENUM_CONVERT(ARDOUR::MeterPoint)
+DEFINE_ENUM_CONVERT(ARDOUR::NoteMode)
+DEFINE_ENUM_CONVERT(ARDOUR::ChannelMode)
+DEFINE_ENUM_CONVERT(ARDOUR::LocaleMode)
+DEFINE_ENUM_CONVERT(ARDOUR::MonitorChoice)
+
+DEFINE_ENUM_CONVERT(ARDOUR::AlignStyle)
+DEFINE_ENUM_CONVERT(ARDOUR::AlignChoice)
+
+DEFINE_ENUM_CONVERT(ARDOUR::WaveformScale)
+DEFINE_ENUM_CONVERT(ARDOUR::WaveformShape)
+DEFINE_ENUM_CONVERT(ARDOUR::VUMeterStandard)
+DEFINE_ENUM_CONVERT(ARDOUR::MeterLineUp)
+
+DEFINE_ENUM_CONVERT(ARDOUR::MidiPortFlags)
+
+DEFINE_ENUM_CONVERT(MusicalMode::Type)
+
+template <>
+inline bool to_string (ARDOUR::AutoState val, std::string& str)
+{
+ str = ARDOUR::auto_state_to_string (val);
+ return true;
+}
+
+template <>
+inline bool string_to (const std::string& str, ARDOUR::AutoState& as)
+{
+ as = ARDOUR::string_to_auto_state (str);
+ return true;
+}
+
+template <>
+inline bool to_string (ARDOUR::AutoStyle val, std::string& str)
+{
+ str = ARDOUR::auto_style_to_string (val);
+ return true;
+}
+
+template <>
+inline bool string_to (const std::string& str, ARDOUR::AutoStyle& as)
+{
+ as = ARDOUR::string_to_auto_style (str);
+ return true;
+}
+
+template <>
+inline bool to_string (ARDOUR::DataType val, std::string& str)
+{
+ str = val.to_string();
+ return true;
+}
+
+template <>
+inline bool string_to (const std::string& str, ARDOUR::DataType& dt)
+{
+ dt = ARDOUR::DataType(str);
+ return true;
+}
+
+} // namespace PBD
+
+#endif // ARDOUR_TYPES_CONVERT_H