diff options
author | Tim Mayberry <mojofunk@gmail.com> | 2016-08-25 01:33:42 +1000 |
---|---|---|
committer | Tim Mayberry <mojofunk@gmail.com> | 2017-04-19 09:36:47 +1000 |
commit | 7c4c58ba34115470f8c3147384d7bd0bfc6b3fdb (patch) | |
tree | 98de3f4d0f6d130acf394d2f160cfadf96c2de64 /libs/ardour/ardour/evoral_types_convert.h | |
parent | 911e2af0181ecc4d937cbfd9a926b1d527e7ae42 (diff) |
Add header for PBD::to_string/_to template specializations for Evoral types
Diffstat (limited to 'libs/ardour/ardour/evoral_types_convert.h')
-rw-r--r-- | libs/ardour/ardour/evoral_types_convert.h | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/libs/ardour/ardour/evoral_types_convert.h b/libs/ardour/ardour/evoral_types_convert.h new file mode 100644 index 0000000000..38d6c61e99 --- /dev/null +++ b/libs/ardour/ardour/evoral_types_convert.h @@ -0,0 +1,67 @@ +/* + 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_EVORAL_TYPES_CONVERT_H +#define ARDOUR_EVORAL_TYPES_CONVERT_H + +#include "pbd/enum_convert.h" + +#include "evoral/Beats.hpp" +#include "evoral/ControlList.hpp" + +namespace PBD { + +DEFINE_ENUM_CONVERT(Evoral::ControlList::InterpolationStyle) + +template <> +inline bool to_string (Evoral::Beats beats, std::string& str) +{ + return double_to_string (beats.to_double (), str); +} + +template <> +inline bool string_to (const std::string& str, Evoral::Beats& beats) +{ + double tmp; + if (!string_to_double (str, tmp)) { + return false; + } + beats = Evoral::Beats(tmp); + return true; +} + +template <> +inline std::string to_string (Evoral::Beats beats) +{ + std::string tmp; + double_to_string (beats.to_double (), tmp); + return tmp; +} + +template <> +inline Evoral::Beats string_to (const std::string& str) +{ + double tmp; + string_to_double (str, tmp); + return Evoral::Beats (tmp); +} + +} // namespace PBD + +#endif // ARDOUR_EVORAL_TYPES_CONVERT_H |