/*************************************************************************** * Copyright (C) 2008-2016 by Andrzej Rybczak * * electricityispower@gmail.com * * * * 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., * * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ #ifndef NCMPCPP_HAVE_FORMAT_H #define NCMPCPP_HAVE_FORMAT_H #include #include "curses/menu.h" #include "song.h" namespace Format { namespace Flags { const unsigned None = 0; const unsigned Color = 1; const unsigned Format = 2; const unsigned OutputSwitch = 4; const unsigned Tag = 8; const unsigned All = Color | Format | OutputSwitch | Tag; } enum class ListType { Group, FirstOf, AST }; template struct List; template using Group = List; template using FirstOf = List; template using AST = List; struct OutputSwitch { }; struct SongTag { SongTag(MPD::Song::GetFunction function_, unsigned delimiter_ = 0) : m_function(function_), m_delimiter(delimiter_) { } MPD::Song::GetFunction function() const { return m_function; } unsigned delimiter() const { return m_delimiter; } private: MPD::Song::GetFunction m_function; unsigned m_delimiter; }; template using SongTagMap = std::vector< std::pair > >; enum class Result { Empty, Missing, Ok }; template using Expression = boost::variant< std::basic_string, NC::Color, NC::Format, OutputSwitch, SongTag, boost::recursive_wrapper>, boost::recursive_wrapper> >; template struct List { typedef std::vector> Base; List() { } List(Base &&base_) : m_base(std::move(base_)) { } Base &base() { return m_base; } const Base &base() const { return m_base; } private: Base m_base; }; template void visit(VisitorT &visitor, const AST &ast); template void print(const AST &ast, NC::Menu &menu, const MPD::Song *song, NC::BasicBuffer *buffer, const unsigned flags = Flags::All); template void print(const AST &ast, NC::BasicBuffer &buffer, const MPD::Song *song, const unsigned flags = Flags::All); template std::basic_string stringify(const AST &ast, const MPD::Song *song); AST parse(const std::string &s, const unsigned flags = Flags::All); AST parse(const std::wstring &ws, const unsigned flags = Flags::All); } #endif // NCMPCPP_HAVE_FORMAT_H