File indexing completed on 2024-04-28 04:04:48

0001 /***************************************************************************
0002  *   Copyright 2007      Francesco Rossi <redsh@email.it>                  *
0003  *   Copyright 2007      Mick Kappenburg <ksudoku@kappendburg.net>         *
0004  *   Copyright 2007      Johannes Bergmeier <Johannes.Bergmeier@gmx.net>   +
0005  *                                                                         *
0006  *   This program is free software; you can redistribute it and/or modify  *
0007  *   it under the terms of the GNU General Public License as published by  *
0008  *   the Free Software Foundation; either version 2 of the License, or     *
0009  *   (at your option) any later version.                                   *
0010  *                                                                         *
0011  *   This program is distributed in the hope that it will be useful,       *
0012  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
0013  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
0014  *   GNU General Public License for more details.                          *
0015  *                                                                         *
0016  *   You should have received a copy of the GNU General Public License     *
0017  *   along with this program; if not, write to the                         *
0018  *   Free Software Foundation, Inc.,                                       *
0019  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.         *
0020  ***************************************************************************/
0021 
0022 #include "symbols.h"
0023 #include "globals.h"
0024 
0025 #include <QChar>
0026 
0027 namespace ksudoku {
0028 
0029 /// returns the symbol for a value used for loading and saving
0030 QChar Symbols::ioValue2Symbol(int value) {
0031     if (value == VACANT) return QLatin1Char('_');
0032     if (value == UNUSABLE) return QLatin1Char('.');
0033     return QLatin1Char('a' + value);
0034 }
0035 
0036 /// returns the number of the index
0037 int Symbols::ioSymbol2Value(QChar symbol) {
0038     char c = symbol.toLatin1();
0039     if(symbol == QLatin1Char('_')) return VACANT;
0040     if(symbol == QLatin1Char('.')) return UNUSABLE;
0041     return c - 'a';
0042 }
0043 
0044 }