Updated German translation
[dasher.git] / Src / DasherCore / WordGeneratorBase.cpp
blobc3bc3828fe85f5c8351068f61b9bf671ce1ca5b6
1 #include "WordGeneratorBase.h"
3 using namespace Dasher;
5 CWordGeneratorBase::CWordGeneratorBase(const CAlphInfo *pAlph, const CAlphabetMap *pAlphMap) : m_pAlph(pAlph), m_pAlphMap(pAlphMap) {
8 void CWordGeneratorBase::GetSymbols(std::vector<symbol> &into) {
9 for (;;) {
10 string s(GetLine());
11 if (s.empty()) break; //no more lines, so no more symbols...
12 stringstream line(s);
13 CAlphabetMap::SymbolStream ss(line);
14 for (int sym; (sym=ss.next(m_pAlphMap))!=-1; ) {
15 if (!into.empty()) {
16 const symbol lastSym(into.back());
17 if (sym==0 && lastSym == m_pAlph->GetSpaceSymbol()) continue; //skip unknown after space
18 if (lastSym==0) {
19 //convert last sym to a space, or combine with next sym
20 into.pop_back();
21 if (sym!=0 && sym!=m_pAlph->GetSpaceSymbol())
22 into.push_back(m_pAlph->GetSpaceSymbol());
25 into.push_back(sym);
27 if (!into.empty()) {
28 if (into.back()==0) into.pop_back();
29 if (!into.empty()) break;
31 //didn't find any usable symbols in line! repeat...