diff options
author | John Fultz <jfultz@wolfram.com> | 2015-09-07 14:19:46 -0500 |
---|---|---|
committer | John Fultz <jfultz@wolfram.com> | 2015-09-07 15:45:41 -0500 |
commit | 5350a57f1be22b28914fca14225c73dac5b30b24 (patch) | |
tree | 399a309a1302d30ec83cc5d7281ac7286882523a /quackleio/dawgfactory.cpp | |
parent | 9ea9637922ca68d24d7517cf61870d8cee31f6c5 (diff) |
Auto-generate gaddags
Need to add a user interface, but gaddags are now
auto-generated if they can't be found.
Some specific improvements here:
* FixedLengthString gained a pop_back member.
* Add code to allow v1 gaddags and v0 dawgs to work
together.
* Change memory allocation of dawgs and gaddags to
be dynamic (the old limit didn't accommodate the
ridiculously large Polish dictionary in the gaddag)
* The Settings class now knows a bit about generating
gaddags. This will be important for giving UI feedback.
* Fixed several places using filenames which should be
using string, not UVString.
* Dawg/GaddagFactory should have been using
UVString, not QString. My misunderstanding.
Diffstat (limited to 'quackleio/dawgfactory.cpp')
-rw-r--r-- | quackleio/dawgfactory.cpp | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/quackleio/dawgfactory.cpp b/quackleio/dawgfactory.cpp index 74b4346..3a971a3 100644 --- a/quackleio/dawgfactory.cpp +++ b/quackleio/dawgfactory.cpp @@ -25,10 +25,10 @@ #include "util.h" -DawgFactory::DawgFactory(const QString& alphabetFile) +DawgFactory::DawgFactory(const UVString& alphabetFile) { QuackleIO::FlexibleAlphabetParameters *flexure = new QuackleIO::FlexibleAlphabetParameters; - flexure->load(alphabetFile); + flexure->load(QuackleIO::Util::uvStringToQString(alphabetFile)); m_alphas = flexure; m_root.insmallerdict = false; @@ -45,12 +45,10 @@ DawgFactory::~DawgFactory() delete m_alphas; } -bool DawgFactory::pushWord(const QString& word, bool inSmaller, int playability) +bool DawgFactory::pushWord(const UVString& word, bool inSmaller, int playability) { - UVString originalString = QuackleIO::Util::qstringToString(word); - UVString leftover; - Quackle::LetterString encodedWord = m_alphas->encode(originalString, &leftover); + Quackle::LetterString encodedWord = m_alphas->encode(word, &leftover); if (leftover.empty()) { if (m_root.pushWord(encodedWord, inSmaller, playability)) @@ -129,9 +127,9 @@ void DawgFactory::generate() m_root.print(m_nodelist); } -void DawgFactory::writeIndex(const QString& filename) +void DawgFactory::writeIndex(const UVString& filename) { - ofstream out(QuackleIO::Util::qstringToStdString(filename).c_str(), ios::out | ios::binary); + ofstream out(filename.c_str(), ios::out | ios::binary); unsigned char bytes[7]; bytes[0] = (m_encodableWords & 0x00FF0000) >> 16; |