From dc92d571f4f97f6420fdf1a94cc41c1d2808d71b Mon Sep 17 00:00:00 2001 From: John Fultz Date: Sun, 9 Aug 2015 05:13:19 -0500 Subject: Progress on edit lexicon dialog. * Files can now be loaded from user directory as well as app directory. * Edit lexicon dialog has been added, and pretty much all of the GUI elements framed out. Not actually implemented, yet. * Embiggen the board configuration dialog. * Some bits of code refactoring. --- test/testharness.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test') diff --git a/test/testharness.cpp b/test/testharness.cpp index 64847d1..683443f 100644 --- a/test/testharness.cpp +++ b/test/testharness.cpp @@ -191,7 +191,7 @@ void TestHarness::startUp() UVcout << "Starting up."; m_dataManager.setBackupLexicon("twl06"); - m_dataManager.setDataDirectory("../data"); + m_dataManager.setAppDataDirectory("../data"); QString alphabetFile = QuackleIO::Util::stdStringToQString(Quackle::AlphabetParameters::findAlphabetFile(QuackleIO::Util::qstringToStdString(m_alphabet) + ".quackle_alphabet")); QuackleIO::FlexibleAlphabetParameters *flexure = new QuackleIO::FlexibleAlphabetParameters; -- cgit v1.2.3 From 1f7b8ef6f96e1d5a2c50565a0f52cc633215e485 Mon Sep 17 00:00:00 2001 From: John Fultz Date: Mon, 24 Aug 2015 04:45:27 -0500 Subject: Version the GADDAGs. Basically the same thing I just did to the DAWG files, now done to GADDAGs. Also, add hashing, and make sure GADDAGs only load if their hash matches that of the DAWG files. --- lexiconparameters.cpp | 52 +++++++++++++++++++++++++++++--------- lexiconparameters.h | 15 +++++------ quacker/settings.cpp | 19 +++++++------- quackleio/dawgfactory.cpp | 1 + quackleio/gaddagfactory.cpp | 61 ++++++++++++++++++++++++++++++--------------- quackleio/gaddagfactory.h | 23 +++++++++-------- quackletest.cpp | 4 +-- test/testharness.cpp | 6 ++--- 8 files changed, 117 insertions(+), 64 deletions(-) (limited to 'test') diff --git a/lexiconparameters.cpp b/lexiconparameters.cpp index ca09fa5..e014048 100644 --- a/lexiconparameters.cpp +++ b/lexiconparameters.cpp @@ -19,13 +19,14 @@ #include #include + #include "datamanager.h" #include "lexiconparameters.h" #include "uv.h" using namespace Quackle; -class Quackle::V0DawgInterpreter : public DawgInterpreter +class Quackle::V0LexiconInterpreter : public LexiconInterpreter { virtual void loadDawg(ifstream &file, LexiconParameters &lexparams) @@ -39,6 +40,17 @@ class Quackle::V0DawgInterpreter : public DawgInterpreter } } + virtual void loadGaddag(ifstream &file, LexiconParameters &lexparams) + { + int i = 0; + file.unget(); + while (!file.eof()) + { + file.read((char*)(lexparams.m_gaddag) + i, 4); + i += 4; + } + } + virtual void dawgAt(const unsigned char *dawg, int index, unsigned int &p, Letter &letter, bool &t, bool &lastchild, bool &british, int &playability) const { index *= 7; @@ -55,7 +67,7 @@ class Quackle::V0DawgInterpreter : public DawgInterpreter virtual int versionNumber() const { return 0; } }; -class Quackle::V1DawgInterpreter : public DawgInterpreter +class Quackle::V1LexiconInterpreter : public LexiconInterpreter { virtual void loadDawg(ifstream &file, LexiconParameters &lexparams) @@ -72,6 +84,24 @@ class Quackle::V1DawgInterpreter : public DawgInterpreter } } + virtual void loadGaddag(ifstream &file, LexiconParameters &lexparams) + { + char hash[16]; + file.read(hash, sizeof(hash)); + if (memcmp(hash, lexparams.m_hash, sizeof(hash))) + { + lexparams.unloadGaddag(); // don't use a mismatched gaddag + return; + } + + int i = 0; + while (!file.eof()) + { + file.read((char*)(lexparams.m_gaddag) + i, 4); + i += 4; + } + } + virtual void dawgAt(const unsigned char *dawg, int index, unsigned int &p, Letter &letter, bool &t, bool &lastchild, bool &british, int &playability) const { index *= 7; @@ -108,14 +138,14 @@ void LexiconParameters::unloadAll() void LexiconParameters::unloadDawg() { delete[] m_dawg; - m_dawg = 0; + m_dawg = NULL; delete m_interpreter; } void LexiconParameters::unloadGaddag() { delete[] m_gaddag; - m_gaddag = 0; + m_gaddag = NULL; } void LexiconParameters::loadDawg(const string &filename) @@ -133,10 +163,10 @@ void LexiconParameters::loadDawg(const string &filename) switch(versionByte) { case 0: - m_interpreter = new V0DawgInterpreter(); + m_interpreter = new V0LexiconInterpreter(); break; case 1: - m_interpreter = new V1DawgInterpreter(); + m_interpreter = new V1LexiconInterpreter(); break; default: UVcout << "couldn't open dawg " << filename.c_str() << endl; @@ -160,14 +190,12 @@ void LexiconParameters::loadGaddag(const string &filename) return; } + char versionByte = file.get(); + if (versionByte != m_interpreter->versionNumber()) + return; m_gaddag = new unsigned char[40000000]; - int i = 0; - while (!file.eof()) - { - file.read((char*)(m_gaddag) + i, 4); - i += 4; - } + m_interpreter->loadGaddag(file, *this); } string LexiconParameters::findDictionaryFile(const string &lexicon) diff --git a/lexiconparameters.h b/lexiconparameters.h index 4b6369d..04ad4e7 100644 --- a/lexiconparameters.h +++ b/lexiconparameters.h @@ -25,22 +25,23 @@ namespace Quackle { -class DawgInterpreter +class LexiconInterpreter { public: virtual void loadDawg(ifstream &file, LexiconParameters &lexparams) = 0; + virtual void loadGaddag(ifstream &file, LexiconParameters &lexparams) = 0; virtual void dawgAt(const unsigned char *dawg, int index, unsigned int &p, Letter &letter, bool &t, bool &lastchild, bool &british, int &playability) const = 0; virtual int versionNumber() const = 0; - virtual ~DawgInterpreter() {}; + virtual ~LexiconInterpreter() {}; }; -class V0DawgInterpreter; -class V1DawgInterpreter; +class V0LexiconInterpreter; +class V1LexiconInterpreter; class LexiconParameters { - friend class Quackle::V0DawgInterpreter; - friend class Quackle::V1DawgInterpreter; + friend class Quackle::V0LexiconInterpreter; + friend class Quackle::V1LexiconInterpreter; public: LexiconParameters(); @@ -79,7 +80,7 @@ protected: unsigned char *m_dawg; unsigned char *m_gaddag; string m_lexiconName; - DawgInterpreter *m_interpreter; + LexiconInterpreter *m_interpreter; char m_hash[16]; int m_wordcount; }; diff --git a/quacker/settings.cpp b/quacker/settings.cpp index 3c42a39..362e916 100644 --- a/quacker/settings.cpp +++ b/quacker/settings.cpp @@ -207,16 +207,6 @@ void Settings::setQuackleToUseLexiconName(const string &lexiconName) { QUACKLE_LEXICON_PARAMETERS->setLexiconName(lexiconName); - string gaddagFile = Quackle::LexiconParameters::findDictionaryFile(lexiconName + ".gaddag"); - - if (gaddagFile.empty()) - { - UVcout << "Gaddag for lexicon '" << lexiconName << "' does not exist." << endl; - QUACKLE_LEXICON_PARAMETERS->unloadGaddag(); - } - else - QUACKLE_LEXICON_PARAMETERS->loadGaddag(gaddagFile); - string dawgFile = Quackle::LexiconParameters::findDictionaryFile(lexiconName + ".dawg"); if (dawgFile.empty()) { @@ -226,6 +216,15 @@ void Settings::setQuackleToUseLexiconName(const string &lexiconName) else QUACKLE_LEXICON_PARAMETERS->loadDawg(dawgFile); + string gaddagFile = Quackle::LexiconParameters::findDictionaryFile(lexiconName + ".gaddag"); + if (gaddagFile.empty()) + { + UVcout << "Gaddag for lexicon '" << lexiconName << "' does not exist." << endl; + QUACKLE_LEXICON_PARAMETERS->unloadGaddag(); + } + else + QUACKLE_LEXICON_PARAMETERS->loadGaddag(gaddagFile); + QUACKLE_STRATEGY_PARAMETERS->initialize(lexiconName); } } diff --git a/quackleio/dawgfactory.cpp b/quackleio/dawgfactory.cpp index 6fb5be0..74b4346 100644 --- a/quackleio/dawgfactory.cpp +++ b/quackleio/dawgfactory.cpp @@ -138,6 +138,7 @@ void DawgFactory::writeIndex(const QString& filename) bytes[1] = (m_encodableWords & 0x0000FF00) >> 8; bytes[2] = (m_encodableWords & 0x000000FF); + out.put(1); // DAWG format version 1 out.write(m_hash.charptr, sizeof(m_hash.charptr)); out.write((char*)bytes, 3); diff --git a/quackleio/gaddagfactory.cpp b/quackleio/gaddagfactory.cpp index e2c726d..7f666cb 100644 --- a/quackleio/gaddagfactory.cpp +++ b/quackleio/gaddagfactory.cpp @@ -19,6 +19,7 @@ #include #include +#include #include "gaddagfactory.h" #include "util.h" @@ -27,18 +28,20 @@ GaddagFactory::GaddagFactory(const QString& alphabetFile) { QuackleIO::FlexibleAlphabetParameters *flexure = new QuackleIO::FlexibleAlphabetParameters; flexure->load(alphabetFile); - alphas = flexure; + m_alphas = flexure; // So the separator is sorted to last. - root.t = false; - root.c = QUACKLE_NULL_MARK; // "_" - root.pointer = 0; - root.lastchild = true; + m_root.t = false; + m_root.c = QUACKLE_NULL_MARK; // "_" + m_root.pointer = 0; + m_root.lastchild = true; + + m_hash.int32ptr[0] = m_hash.int32ptr[1] = m_hash.int32ptr[2] = m_hash.int32ptr[3] = 0; } GaddagFactory::~GaddagFactory() { - delete alphas; + delete m_alphas; } bool GaddagFactory::pushWord(const QString& word) @@ -46,10 +49,14 @@ bool GaddagFactory::pushWord(const QString& word) UVString originalString = QuackleIO::Util::qstringToString(word); UVString leftover; - Quackle::LetterString encodedWord = alphas->encode(originalString, &leftover); + Quackle::LetterString encodedWord = m_alphas->encode(originalString, &leftover); if (leftover.empty()) { ++m_encodableWords; + hashWord(encodedWord); + // FIXME: This hash will fail if duplicate words are passed in. + // But testing for duplicate words isn't so easy without keeping + // an entirely separate list. for (unsigned i = 1; i <= encodedWord.length(); i++) { @@ -64,7 +71,7 @@ bool GaddagFactory::pushWord(const QString& word) for (unsigned j = i; j < encodedWord.length(); j++) newword.push_back(encodedWord[j]); } - gaddagizedWords.push_back(newword); + m_gaddagizedWords.push_back(newword); } return true; } @@ -73,26 +80,40 @@ bool GaddagFactory::pushWord(const QString& word) return false; } +void GaddagFactory::hashWord(const Quackle::LetterString &word) +{ + QCryptographicHash wordhash(QCryptographicHash::Md5); + wordhash.addData(word.constData(), word.length()); + QByteArray wordhashbytes = wordhash.result(); + m_hash.int32ptr[0] ^= ((const int32_t*)wordhashbytes.constData())[0]; + m_hash.int32ptr[1] ^= ((const int32_t*)wordhashbytes.constData())[1]; + m_hash.int32ptr[2] ^= ((const int32_t*)wordhashbytes.constData())[2]; + m_hash.int32ptr[3] ^= ((const int32_t*)wordhashbytes.constData())[3]; +} + void GaddagFactory::generate() { - Quackle::WordList::const_iterator wordsEnd = gaddagizedWords.end(); - for (Quackle::WordList::const_iterator wordsIt = gaddagizedWords.begin(); wordsIt != wordsEnd; ++wordsIt) - root.pushWord(*wordsIt); + Quackle::WordList::const_iterator wordsEnd = m_gaddagizedWords.end(); + for (Quackle::WordList::const_iterator wordsIt = m_gaddagizedWords.begin(); wordsIt != wordsEnd; ++wordsIt) + m_root.pushWord(*wordsIt); // for (const auto& words : gaddaggizedWords) - // root.pushWord(words); + // m_root.pushWord(words); } -void GaddagFactory::writeIndex(const QString& fname) +void GaddagFactory::writeIndex(const QString &fname) { - nodelist.push_back(&root); + m_nodelist.push_back(&m_root); - root.print(nodelist); + m_root.print(m_nodelist); ofstream out(QuackleIO::Util::qstringToStdString(fname).c_str(), ios::out | ios::binary); - for (size_t i = 0; i < nodelist.size(); i++) + out.put(1); // GADDAG format version 1 + out.write(m_hash.charptr, sizeof(m_hash.charptr)); + + for (size_t i = 0; i < m_nodelist.size(); i++) { - unsigned int p = (unsigned int)(nodelist[i]->pointer); + unsigned int p = (unsigned int)(m_nodelist[i]->pointer); if (p != 0) p -= i; // offset indexing @@ -102,14 +123,14 @@ void GaddagFactory::writeIndex(const QString& fname) unsigned char n3 = (p & 0x000000FF) >> 0; unsigned char n4; - n4 = nodelist[i]->c; + n4 = m_nodelist[i]->c; if (n4 == internalSeparatorRepresentation) n4 = QUACKLE_NULL_MARK; - if (nodelist[i]->t) + if (m_nodelist[i]->t) n4 |= 64; - if (nodelist[i]->lastchild) + if (m_nodelist[i]->lastchild) n4 |= 128; bytes[0] = n1; bytes[1] = n2; bytes[2] = n3; bytes[3] = n4; diff --git a/quackleio/gaddagfactory.h b/quackleio/gaddagfactory.h index 9eb8d72..2d21192 100644 --- a/quackleio/gaddagfactory.h +++ b/quackleio/gaddagfactory.h @@ -30,13 +30,14 @@ public: GaddagFactory(const QString& alphabetFile); ~GaddagFactory(); - int wordCount() const { return gaddagizedWords.size(); }; - int nodeCount() const { return nodelist.size(); }; + int wordCount() const { return m_gaddagizedWords.size(); }; + int nodeCount() const { return m_nodelist.size(); }; int encodableWords() const { return m_encodableWords; }; int unencodableWords() const { return m_unencodableWords; }; bool pushWord(const QString& word); - void sortWords() { sort(gaddagizedWords.begin(), gaddagizedWords.end()); }; + void hashWord(const Quackle::LetterString &word); + void sortWords() { sort(m_gaddagizedWords.begin(), m_gaddagizedWords.end()); }; void generate(); void writeIndex(const QString& fname); @@ -49,17 +50,19 @@ private: int pointer; bool lastchild; void pushWord(const Quackle::LetterString& word); - void print(vector< Node* >& nodelist); + void print(vector< Node* >& m_nodelist); }; int m_encodableWords; int m_unencodableWords; - Quackle::WordList gaddagizedWords; - vector< Node* > nodelist; - Quackle::AlphabetParameters *alphas; - Node root; - - + Quackle::WordList m_gaddagizedWords; + vector< Node* > m_nodelist; + Quackle::AlphabetParameters *m_alphas; + Node m_root; + union { + char charptr[16]; + int32_t int32ptr[4]; + } m_hash; }; #endif diff --git a/quackletest.cpp b/quackletest.cpp index e69c2cb..7ea5d10 100644 --- a/quackletest.cpp +++ b/quackletest.cpp @@ -47,7 +47,7 @@ int main() dataManager.setAppDataDirectory("data"); dataManager.lexiconParameters()->loadDawg(Quackle::LexiconParameters::findDictionaryFile("twl06.dawg")); - dataManager.lexiconParameters()->loadGaddag(Quackle::LexiconParameters::findDictionaryFile("twl06.gaddag")); + dataManager.lexiconParameters()->loadGaddag(Quackle::LexiconParameters::findDictionaryFile("twl06.gaddag")); dataManager.strategyParameters()->initialize("twl06"); dataManager.setBoardParameters(new Quackle::EnglishBoard()); @@ -58,7 +58,7 @@ int main() const int gameCnt = 1000; //const int gameCnt = 1; for (int game = 0; game < gameCnt; ++game) { - testGame(); + testGame(); } return 0; diff --git a/test/testharness.cpp b/test/testharness.cpp index 683443f..3f390c1 100644 --- a/test/testharness.cpp +++ b/test/testharness.cpp @@ -207,13 +207,13 @@ void TestHarness::startUp() m_dataManager.setBoardParameters(new ScrabbleBoard()); - m_dataManager.lexiconParameters()->loadGaddag(Quackle::LexiconParameters::findDictionaryFile(QuackleIO::Util::qstringToStdString(m_lexicon + ".gaddag"))); + m_dataManager.lexiconParameters()->loadDawg(Quackle::LexiconParameters::findDictionaryFile(QuackleIO::Util::qstringToStdString(m_lexicon + ".dawg"))); UVcout << "."; - m_dataManager.lexiconParameters()->loadDawg(Quackle::LexiconParameters::findDictionaryFile(QuackleIO::Util::qstringToStdString(m_lexicon + ".dawg"))); + m_dataManager.lexiconParameters()->loadGaddag(Quackle::LexiconParameters::findDictionaryFile(QuackleIO::Util::qstringToStdString(m_lexicon + ".gaddag"))); + UVcout << "."; m_dataManager.strategyParameters()->initialize(QuackleIO::Util::qstringToStdString(m_lexicon)); - UVcout << "."; UVcout << endl; -- cgit v1.2.3 From 03b9132b3f540bfb3713400774a9bfb832b200b2 Mon Sep 17 00:00:00 2001 From: John Fultz Date: Mon, 28 Sep 2015 12:58:30 -0500 Subject: Some minor refactoring. --- alphabetparameters.cpp | 6 +++--- quacker/lister.cpp | 3 --- quacker/settings.cpp | 2 +- test/testharness.cpp | 2 +- 4 files changed, 5 insertions(+), 8 deletions(-) (limited to 'test') diff --git a/alphabetparameters.cpp b/alphabetparameters.cpp index 851d8ff..4830313 100644 --- a/alphabetparameters.cpp +++ b/alphabetparameters.cpp @@ -214,7 +214,7 @@ LetterString AlphabetParameters::encode(const UVString &word, UVString *leftover if (lookupIt == lookupEnd) { for (alphabetIt = m_alphabet.begin(); alphabetIt != alphabetEnd; ++alphabetIt) - if ((*alphabetIt).blankText() == query) + if (alphabetIt->blankText() == query) break; if (alphabetIt == alphabetEnd) @@ -224,7 +224,7 @@ LetterString AlphabetParameters::encode(const UVString &word, UVString *leftover } blank = true; - ret += blank? setBlankness((*alphabetIt).letter()) : (*alphabetIt).letter(); + ret += blank? setBlankness(alphabetIt->letter()) : alphabetIt->letter(); } else { ret += blank? setBlankness(m_alphabet[lookupIt->second].letter()) : m_alphabet[lookupIt->second].letter(); } @@ -241,7 +241,7 @@ LetterString AlphabetParameters::encode(const UVString &word, UVString *leftover string AlphabetParameters::findAlphabetFile(const string &alphabet) { - return DataManager::self()->findDataFile("alphabets", alphabet); + return DataManager::self()->findDataFile("alphabets", alphabet + ".quackle_alphabet"); } //////// diff --git a/quacker/lister.cpp b/quacker/lister.cpp index 278bff1..be3e335 100644 --- a/quacker/lister.cpp +++ b/quacker/lister.cpp @@ -667,7 +667,6 @@ void NumAnagramsFilter::apply() { int twl = 0; int british = 0; - int playability = 0; QString alphagram(QuackleIO::DictFactory::querier()->alphagram((*it).word)); for (Dict::WordList::Iterator word = map[alphagram].begin(); word != map[alphagram].end(); ++word) @@ -676,8 +675,6 @@ void NumAnagramsFilter::apply() british++; else twl++; - - playability += (*word).playability; } if ((twl == numTwlAnagrams) && (british == numOswOnlyAnagrams)) diff --git a/quacker/settings.cpp b/quacker/settings.cpp index 1febdb5..ce8583f 100644 --- a/quacker/settings.cpp +++ b/quacker/settings.cpp @@ -283,7 +283,7 @@ void Settings::setQuackleToUseAlphabetName(const QString &alphabetName) string alphabetNameStr = alphabetName.toStdString(); if (QUACKLE_ALPHABET_PARAMETERS->alphabetName() != alphabetNameStr) { - QString alphabetFileStr = QuackleIO::Util::stdStringToQString(Quackle::AlphabetParameters::findAlphabetFile(alphabetNameStr + ".quackle_alphabet")); + QString alphabetFileStr = QuackleIO::Util::stdStringToQString(Quackle::AlphabetParameters::findAlphabetFile(alphabetNameStr)); QuackleIO::FlexibleAlphabetParameters *flexure = new QuackleIO::FlexibleAlphabetParameters; flexure->setAlphabetName(alphabetNameStr); diff --git a/test/testharness.cpp b/test/testharness.cpp index 3f390c1..172e403 100644 --- a/test/testharness.cpp +++ b/test/testharness.cpp @@ -193,7 +193,7 @@ void TestHarness::startUp() m_dataManager.setBackupLexicon("twl06"); m_dataManager.setAppDataDirectory("../data"); - QString alphabetFile = QuackleIO::Util::stdStringToQString(Quackle::AlphabetParameters::findAlphabetFile(QuackleIO::Util::qstringToStdString(m_alphabet) + ".quackle_alphabet")); + QString alphabetFile = QuackleIO::Util::stdStringToQString(Quackle::AlphabetParameters::findAlphabetFile(QuackleIO::Util::qstringToStdString(m_alphabet))); QuackleIO::FlexibleAlphabetParameters *flexure = new QuackleIO::FlexibleAlphabetParameters; if (flexure->load(alphabetFile)) { -- cgit v1.2.3 From 86e8d2a1247e8c6b00cefda10b2a96376a1540ca Mon Sep 17 00:00:00 2001 From: John Fultz Date: Wed, 14 Oct 2015 04:37:27 -0500 Subject: Windows build fixes. --- encodeleaves/encodeleaves.pro | 10 +++++++--- makegaddag/makegaddag.cpp | 6 +++--- makegaddag/makegaddag.pro | 10 +++++++--- makeminidawg/makeminidawg.pro | 10 +++++++--- makeminidawg/makeminidawgmain.cpp | 2 +- quacker/quacker.pro | 11 ++++------- quackle.pro | 2 ++ quackleio/dawgfactory.h | 3 ++- quackleio/gaddagfactory.h | 3 ++- quackleio/iotest/iotest.pro | 10 +++++++--- quackleio/quackleio.pro | 2 ++ test/test.pro | 10 +++++++--- 12 files changed, 51 insertions(+), 28 deletions(-) (limited to 'test') diff --git a/encodeleaves/encodeleaves.pro b/encodeleaves/encodeleaves.pro index f1a51bb..559df28 100644 --- a/encodeleaves/encodeleaves.pro +++ b/encodeleaves/encodeleaves.pro @@ -11,16 +11,20 @@ CONFIG -= app_bundle debug { OBJECTS_DIR = obj/debug + QMAKE_LIBDIR += ../lib/debug ../quackleio/lib/debug } release { OBJECTS_DIR = obj/release + QMAKE_LIBDIR += ../lib/release ../quackleio/lib/release } -LIBS += -lquackleio -lquackle +win32:!win32-g++ { + LIBS += -lquackleio -llibquackle +} else { + LIBS += -lquackleio -lquackle +} -QMAKE_LFLAGS_RELEASE += -L../lib/release -L../quackleio/lib/release -QMAKE_LFLAGS_DEBUG += -L../lib/debug -L../quackleio/lib/debug # Input SOURCES += encodeleaves.cpp diff --git a/makegaddag/makegaddag.cpp b/makegaddag/makegaddag.cpp index 7a768cd..ef2c439 100644 --- a/makegaddag/makegaddag.cpp +++ b/makegaddag/makegaddag.cpp @@ -62,7 +62,7 @@ int main(int argc, char **argv) QString alphabetFile = QString("../data/alphabets/%1.quackle_alphabet").arg(alphabet); UVcout << "Using alphabet file: " << QuackleIO::Util::qstringToString(alphabetFile) << endl; - GaddagFactory factory(alphabetFile); + GaddagFactory factory(QuackleIO::Util::qstringToString(alphabetFile)); QFile file(inputFilename); if (!file.exists()) @@ -88,7 +88,7 @@ int main(int argc, char **argv) if (stream.atEnd()) break; - if (!factory.pushWord(originalQString)) + if (!factory.pushWord(QuackleIO::Util::qstringToString(originalQString))) UVcout << "not encodable without leftover: " << QuackleIO::Util::qstringToString(originalQString) << endl; } @@ -99,7 +99,7 @@ int main(int argc, char **argv) factory.generate(); UVcout << "Writing index..."; - factory.writeIndex(outputFilename); + factory.writeIndex(outputFilename.toUtf8().constData()); UVcout << endl; diff --git a/makegaddag/makegaddag.pro b/makegaddag/makegaddag.pro index dfd1259..9895c99 100755 --- a/makegaddag/makegaddag.pro +++ b/makegaddag/makegaddag.pro @@ -5,10 +5,12 @@ CONFIG += release debug { OBJECTS_DIR = obj/debug + QMAKE_LIBDIR += ../lib/debug ../quackleio/lib/debug } release { OBJECTS_DIR = obj/release + QMAKE_LIBDIR += ../lib/release ../quackleio/lib/release } MOC_DIR = moc @@ -19,10 +21,12 @@ MOC_DIR = moc CONFIG += console CONFIG -= app_bundle -LIBS += -lquackleio -lquackle +win32:!win32-g++ { + LIBS += -lquackleio -llibquackle +} else { + LIBS += -lquackleio -lquackle +} -QMAKE_LFLAGS_RELEASE += -L../lib/release -L../quackleio/lib/release -QMAKE_LFLAGS_DEBUG += -L../lib/debug -L../quackleio/lib/debug # Input SOURCES += makegaddag.cpp diff --git a/makeminidawg/makeminidawg.pro b/makeminidawg/makeminidawg.pro index 729e6b4..e728a8a 100644 --- a/makeminidawg/makeminidawg.pro +++ b/makeminidawg/makeminidawg.pro @@ -12,16 +12,20 @@ CONFIG -= app_bundle debug { OBJECTS_DIR = obj/debug + QMAKE_LIBDIR += ../lib/debug ../quackleio/lib/debug } release { OBJECTS_DIR = obj/release + QMAKE_LIBDIR += ../lib/release ../quackleio/lib/release } -LIBS += -lquackleio -lquackle +win32:!win32-g++ { + LIBS += -lquackleio -llibquackle +} else { + LIBS += -lquackleio -lquackle +} -QMAKE_LFLAGS_RELEASE += -L../lib/release -L../quackleio/lib/release -QMAKE_LFLAGS_DEBUG += -L../lib/debug -L../quackleio/lib/debug # Input HEADERS += diff --git a/makeminidawg/makeminidawgmain.cpp b/makeminidawg/makeminidawgmain.cpp index eee2b37..dfd3c82 100644 --- a/makeminidawg/makeminidawgmain.cpp +++ b/makeminidawg/makeminidawgmain.cpp @@ -125,7 +125,7 @@ int main(int argc, char **argv) if (stream.atEnd()) break; - if (!factory.pushWord(word, inSmaller, pb)) + if (!factory.pushWord(QuackleIO::Util::qstringToString(word), inSmaller, pb)) UVcout << "not encodable without leftover: " << QuackleIO::Util::qstringToString(word) << endl; } diff --git a/quacker/quacker.pro b/quacker/quacker.pro index 9906e45..8bd1e4f 100644 --- a/quacker/quacker.pro +++ b/quacker/quacker.pro @@ -12,17 +12,12 @@ CONFIG += release debug { OBJECTS_DIR = obj/debug + QMAKE_LIBDIR += ../lib/debug ../quackleio/lib/debug } release { OBJECTS_DIR = obj/release -} - -debug { - QMAKE_LIBDIR += ../lib/debug ../quackleio/lib/debug -} -release { - QMAKE_LIBDIR += ../lib/release ../quackleio/lib/release + QMAKE_LIBDIR += ../lib/release ../quackleio/lib/release } win32:!win32-g++ { @@ -32,6 +27,8 @@ win32:!win32-g++ { } macx:LIBS += -framework CoreFoundation +QMAKE_CXXFLAGS += -std=c++11 + # Input HEADERS += *.h SOURCES += *.cpp diff --git a/quackle.pro b/quackle.pro index 18d9a33..4bd40f4 100644 --- a/quackle.pro +++ b/quackle.pro @@ -17,6 +17,8 @@ release { DESTDIR = lib/release } +QMAKE_CXXFLAGS += -std=c++11 + # enable/disable debug symbols #CONFIG += debug staticlib CONFIG += release staticlib diff --git a/quackleio/dawgfactory.h b/quackleio/dawgfactory.h index efcc455..7af4d68 100644 --- a/quackleio/dawgfactory.h +++ b/quackleio/dawgfactory.h @@ -19,6 +19,7 @@ #ifndef QUACKLE_DAWGFACTORY_H #define QUACKLE_DAWGFACTORY_H +#include #include #include #include "flexiblealphabet.h" @@ -82,7 +83,7 @@ private: Node m_root; union { char charptr[16]; - int32_t int32ptr[4]; + std::int32_t int32ptr[4]; } m_hash; static const char m_versionNumber = 1; diff --git a/quackleio/gaddagfactory.h b/quackleio/gaddagfactory.h index 415baff..3017085 100644 --- a/quackleio/gaddagfactory.h +++ b/quackleio/gaddagfactory.h @@ -19,6 +19,7 @@ #ifndef QUACKLE_GADDAGFACTORY_H #define QUACKLE_GADDAGFACTORY_H +#include #include "flexiblealphabet.h" @@ -65,7 +66,7 @@ private: Node m_root; union { char charptr[16]; - int32_t int32ptr[4]; + std::int32_t int32ptr[4]; } m_hash; }; diff --git a/quackleio/iotest/iotest.pro b/quackleio/iotest/iotest.pro index 0bf472e..c7e994f 100644 --- a/quackleio/iotest/iotest.pro +++ b/quackleio/iotest/iotest.pro @@ -8,16 +8,20 @@ CONFIG += release debug { OBJECTS_DIR = obj/debug + QMAKE_LIBDIR += ../../lib/debug ../../quackleio/lib/debug } release { OBJECTS_DIR = obj/release + QMAKE_LIBDIR += ../../lib/release ../../quackleio/lib/release } -LIBS += -lquackleio -lquackle +win32:!win32-g++ { + LIBS += -lquackleio -llibquackle +} else { + LIBS += -lquackleio -lquackle +} -QMAKE_LFLAGS_RELEASE += -L../../lib/release -L../../quackleio/lib/release -QMAKE_LFLAGS_DEBUG += -L../../lib/debug -L../../quackleio/lib/debug # Input HEADERS += trademarkedboards.h diff --git a/quackleio/quackleio.pro b/quackleio/quackleio.pro index 195b0ad..8e43d29 100644 --- a/quackleio/quackleio.pro +++ b/quackleio/quackleio.pro @@ -15,6 +15,8 @@ release { MOC_DIR = moc +QMAKE_CXXFLAGS += -std=c++11 + # enable/disable debug symbols #CONFIG += debug staticlib CONFIG += release staticlib diff --git a/test/test.pro b/test/test.pro index 0284f47..99a378e 100644 --- a/test/test.pro +++ b/test/test.pro @@ -12,16 +12,20 @@ CONFIG += release debug { OBJECTS_DIR = obj/debug + QMAKE_LIBDIR += ../lib/debug ../quackleio/lib/debug } release { OBJECTS_DIR = obj/release + QMAKE_LIBDIR += ../lib/release ../quackleio/lib/release } -LIBS += -lquackleio -lquackle +win32:!win32-g++ { + LIBS += -lquackleio -llibquackle +} else { + LIBS += -lquackleio -lquackle +} -QMAKE_LFLAGS_RELEASE += -L../lib/release -L../quackleio/lib/release -QMAKE_LFLAGS_DEBUG += -L../lib/debug -L../quackleio/lib/debug # Input HEADERS += testharness.h trademarkedboards.h -- cgit v1.2.3