/* * This file is a part of QComicBook. * * Copyright (C) 2005-2006 Pawel Stolowski * * QComicBook is free software; you can redestribute it and/or modify it * under terms of GNU General Public License by Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY. See GPL for more details. */ #ifndef __ENUMMAP_H #define __ENUMMAP_H #include namespace Utility { template struct EnumMap { QString str; T val; }; template const QString& convert(const EnumMap *tab, const T &v) { for (int i=0; tab[i].str!=QString::null; i++) if (tab[i].val == v) return tab[i].str; return tab[0].str; } template const T& convert(const EnumMap *tab, const QString &s) { for (int i=0; tab[i].str!=QString::null; i++) if (tab[i].str == s) return tab[i].val; return tab[0].val; } } #endif