lib

kohyphen.h
1/******************************************************************************
2 * Copyright (C) 2002 by Alexander Dymo <cloudtemple@mskat.net> *
3 * Copyright (C) 2002-2003 by Lukas Tinkl <lukas.tinkl@suse.cz> *
4 * Copyright (C) 2003 David Faure <faure@kde.org> *
5 * *
6 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU Library General Public License as *
8 * published by the Free Software Foundation; either version 2 of the *
9 * License, or (at your option) any later version. *
10 * *
11 * This library is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
14 * Library General Public License for more details. *
15 * *
16 * You should have received a copy of the GNU Library General Public License *
17 * along with this library; see the file COPYING.LIB. If not, write to *
18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 * Boston, MA 02110-1301, USA. *
20 ******************************************************************************/
21
22#ifndef KOHYPHEN_H
23#define KOHYPHEN_H
24
25#include <tqmap.h>
26#include <tqstring.h>
27#include "hyphen.h"
28
29class KoHyphenatorException{
30public:
31 KoHyphenatorException(const TQString& MessageText): messageText(MessageText) {}
32 TQString message() const { return messageText; }
33private:
34 TQString messageText;
35};
36
56class KoHyphenator{
57public:
63 static KoHyphenator* self();
64
65 ~KoHyphenator();
66
73 bool checkHyphenPos(const TQString& str, int pos, const TQString& lang) const;
74
91 char *hyphens(const TQString& str, const TQString& lang) const;
92
103 TQString hyphenate(const TQString& str, const TQString& lang) const;
104
105private:
109 TQTextCodec* codecForLang(const TQString& lang) const;
110
111 KoHyphenator();
112 HyphenDict *dict(const TQString &lang) const;
113
114 TQMap<TQString, HyphenDict*> dicts;
115 struct EncodingStruct {
116 EncodingStruct() // for TQMap
117 : encoding(), codec(0L) {}
118 EncodingStruct(const TQCString& _encoding)
119 : encoding(_encoding), codec(0L) {}
120 TQCString encoding;
121 TQTextCodec* codec;
122 };
123 typedef TQMap<TQString, EncodingStruct> EncodingMap;
124 mutable EncodingMap encodings; // key is the language code
125
126 static KoHyphenator* s_self;
127};
128
129#endif
bool checkHyphenPos(const TQString &str, int pos, const TQString &lang) const
Checks if the letter in position pos is placed before the hyphen.
Definition kohyphen.cpp:153
static KoHyphenator * self()
Returns the single KoHyphenator instance (singleton pattern) Beware that this might throw an exceptio...
Definition kohyphen.cpp:41
char * hyphens(const TQString &str, const TQString &lang) const
Returns the pointer to the string in hnj_hyphen_hyphenate() format (that is hyphenation function from...
Definition kohyphen.cpp:98
TQString hyphenate(const TQString &str, const TQString &lang) const
Hyphenates the string str and returns the string with hyphenation marks in it.
Definition kohyphen.cpp:118