Skip to content
This repository has been archived by the owner on May 12, 2020. It is now read-only.

Commit

Permalink
add an option to disable "strip" (trim). fix #2.
Browse files Browse the repository at this point in the history
  • Loading branch information
librehat committed Jan 25, 2015
1 parent 1c0e5f0 commit 8d9f52c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
6 changes: 5 additions & 1 deletion lingoes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
#include <QtEndian>
#include <exception>

Lingoes::Lingoes(const QString &openFile)
Lingoes::Lingoes(const QString &openFile, bool _trim) :
trim(_trim)
{
ld2file = openFile;
QFile file(ld2file);
Expand Down Expand Up @@ -274,6 +275,9 @@ void Lingoes::readDefinitionData(const QByteArray &inflatedBytes, const int offs

QString Lingoes::strip(const QString &xml)
{
if (!trim) {
return xml;
}
/*
* Strip some formats characters.
* TODO: strip HTML tags such as <TD> <TR>
Expand Down
3 changes: 2 additions & 1 deletion lingoes.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class Lingoes : public QObject
Q_OBJECT

public:
Lingoes(const QString &);
Lingoes(const QString &, bool _trim = true);
void extractToFile(const QString &);
int getInt(const int);
int getInt(const QByteArray &, const int);
Expand All @@ -39,6 +39,7 @@ Q_OBJECT
QByteArray toHexString(const qint16);

private:
const bool trim;
int position;
int inflated_pos;
QString ld2file;
Expand Down
10 changes: 7 additions & 3 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,13 @@ int main(int argc, char** argv)
parser.addHelpOption();
parser.addVersionOption();

QCommandLineOption ldxfile("i", "Input Lingoes dictionary file (default: input.ld2)", "input", "input.ld2");
QCommandLineOption outfile("o", "Output extracted text file (default: output.txt)", "output", "output.txt");
QCommandLineOption ldxfile("i", "Input Lingoes dictionary file (default: input.ld2).", "input", "input.ld2");
QCommandLineOption outfile("o", "Output extracted text file (default: output.txt).", "output", "output.txt");
QCommandLineOption notrim("disable-trim", "Disable HTML tag trimming.");

parser.addOption(ldxfile);
parser.addOption(outfile);
parser.addOption(notrim);

parser.process(app);

Expand All @@ -50,7 +53,8 @@ int main(int argc, char** argv)
}

QString ld2file = ld2FileInfo.canonicalFilePath();
Lingoes ldx(ld2file);
bool trim = !parser.isSet(notrim);
Lingoes ldx(ld2file, trim);
ldx.extractToFile(parser.value(outfile));

return 0;
Expand Down

0 comments on commit 8d9f52c

Please sign in to comment.