1
/******************************************************************************
2
 * Copyright (C) 2008 Nicos Gollan <gtdev@spearhead.de>                       *
3
 *               2008 Teo Mrnjavac <teo.mrnjavac@gmail.com>                   *
4
 *                                                                            *
5
 * This program is free software; you can redistribute it and/or              *
6
 * modify it under the terms of the GNU General Public License as             *
7
 * published by the Free Software Foundation; either version 2 of             *
8
 * the License, or (at your option) any later version.                        *
9
 *                                                                            *
10
 * This program is distributed in the hope that it will be useful,            *
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of             *
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the              *
13
 * GNU General Public License for more details.                               *
14
 *                                                                            *
15
 * You should have received a copy of the GNU General Public License          *
16
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.      *
17
 ******************************************************************************/
18
#ifndef CASECONVERTER_H
19
#define CASECONVERTER_H
20
21
#include <QString>
22
23
namespace Amarok
24
{
25
/** Case converter for tag formatting.
26
  *
27
  * Provides helper functions to achieve sane capitalization of tag
28
  * information.
29
  */
30
class CaseConverter
31
{
32
public:
33
    /** Convert to "title case".
34
    *
35
    * Title case tries to conform to the common capitalization of titles,
36
    * i.e. first letter of each word is capitalized, except for "small"
37
    * words like "in", "of", etc.
38
    *
39
    * This implementation will also leave alone words that already have
40
    * some kind of capitalization, assuming that those are properly
41
    * formatted.
42
    *
43
    * @param s A string to be converted
44
    * @return The converted string
45
    */
46
    static QString toTitleCase( const QString &s );
47
    /** Convert to "capitalized case"
48
    *
49
    * Capitalizes the initial letter of each word.
50
    *
51
    * @param s A string to be converted
52
    * @return The converted string
53
    */
54
    static QString toCapitalizedCase( const QString &s );
55
private:
56
    /// regular expression for a word.
57
    static const QString s_MATCH_A_WORD;
58
    /** "small words" that ought not be capitalized.
59
    *
60
    * This is mostly English only.
61
    */
62
    static const QString s_LITTLE_WORDS;
63
};
64
}
65
66
#endif //CASECONVERTER_H