Commit 8f6422b0 authored by Jorand Jean-baptiste's avatar Jorand Jean-baptiste
Browse files

read qstring

parent c2ccc060
Loading
Loading
Loading
Loading
+2 −15
Changes for GUI/mainwindow.cpp: 2 added lines, 15 removed lines.
Original line number Diff line number Diff line
@@ -40,7 +40,7 @@ void MainWindow::findFile() {

void MainWindow::startGame() {
    stats = new Statsgen();
    stats->setFilename(ui->fileLine->text().toStdString());
    stats->setFilename(ui->fileLine->text());

    if(ui->withcountButton->isChecked())
    {
@@ -147,22 +147,9 @@ void MainWindow::startGame() {
    waitBox.setText("Analysis in progress");

    waitBox.exec();
/*
    QFile file(filename);

    if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
        return;

    QTextStream in(&file);
    int c = 0;
    while (!in.atEnd()) {
        QString line = in.readLine();
        c++;
}
    ui->teResult->setText(QString::number(c));
    */

}


void MainWindow::enableWithCount()
{
+18 −7
Changes for GUI/statsgen.cpp: 18 added lines, 7 removed lines.
Original line number Diff line number Diff line
@@ -13,6 +13,7 @@
#include <vector>
#include <thread>
#include <pthread.h>
#include <QFile>


#include "statsgen.h"
@@ -27,7 +28,7 @@ Statsgen::Statsgen() {}



void Statsgen::setFilename(std::string name) {
void Statsgen::setFilename(QString name) {
    filename = name;
}

@@ -63,6 +64,7 @@ void Statsgen::setLimitSimplemask(int val) {
    limitSimplemask = val;
}


void Statsgen::setLimitAdvancedmask(int val) {
    limitAdvancedmask = val;
}
@@ -95,13 +97,13 @@ void Statsgen::setSecurityRules() {
    cin >> minUpper;
}


void Statsgen::setSecurityRules(int length,int special,int digit,int upper,int lower) {
    minLength=length;
    minSpecial=special;
    minDigit=digit;
    minUpper=upper;
    minLower=lower;

}


@@ -273,6 +275,9 @@ void Statsgen::print_stats() {
    }
}




void analyse_letter(const char & letter, char & last_simplemask, wstring & simplemask_string, wstring & advancedmask_string, Policy & policy, int & sizeAdvancedMask, int & sizeSimpleMask) {
    sizeAdvancedMask++;

@@ -424,17 +429,24 @@ void updateMinMax(minMax & minMaxValue, const Policy & pol) {
}




void * generate_stats_thread(void * threadarg) {
    struct thread_data *my_data;
    my_data = (struct thread_data *) threadarg;

    wifstream readfile(my_data->filename);
    QFile file(my_data->filename);
    file.open(QIODevice::ReadOnly | QIODevice::Text);
    QTextStream flux(&file);

    QString qline;
    wstring line;
    int nbline = 0;

    while(readfile.good()) {
    while(! flux.atEnd()) {
        ++nbline;
        getline(readfile, line);
        qline = flux.readLine();

        if (nbline < my_data->lineBegin) {
            continue;
        }
@@ -443,6 +455,7 @@ void * generate_stats_thread(void * threadarg) {
        }


        line = qline.toStdWString();
        if (line.size() == 0) {
            continue;
        }
@@ -491,8 +504,6 @@ void * generate_stats_thread(void * threadarg) {
        updateMinMax(my_data->minMaxValue, c.pol);
    }

    readfile.close();

    pthread_exit(NULL);
}
+3 −3
Changes for GUI/statsgen.h: 3 added lines, 3 removed lines.
Original line number Diff line number Diff line
@@ -75,7 +75,7 @@ struct SecurityRules {
 */
struct thread_data {
	int thread_id;
	std::string filename;
    QString filename;
	int lineBegin;
	int lineEnd;

@@ -110,7 +110,7 @@ public:
	 * @brief Initialise the name of the database
	 * @param : new value for "filename"
	 */
	void setFilename(std::string);
    void setFilename(QString);


	/**
@@ -185,7 +185,7 @@ public:


private:
	std::string filename;
    QString filename;


	// Filters
+12 −5
Changes for GUI/utils.h: 12 added lines, 5 removed lines.
Original line number Diff line number Diff line
@@ -15,6 +15,9 @@
#include <iostream>
#include <fstream>
#include <unordered_map>
#include <QString>
#include <QFile>
#include <QTextStream>
using namespace std;


@@ -68,6 +71,8 @@ void readResult(double res, Type carac, int & count, const double & total_counte
}




/**
 * @brief print an unordered map
 * @param stats : map to show
@@ -102,13 +107,15 @@ void showMap(const unordered_map<Type, double> & stats, const int & top, const d
 * @param filename : name of the file
 * @return : number of line
 */
int nbline_file(const string & filename) {
    wifstream readfile(filename);
    wstring line;
int nbline_file(const QString & filename) {
    QFile file(filename);
    file.open(QIODevice::ReadOnly | QIODevice::Text);
    QTextStream flux(&file);
    int nb = 0;

    while(readfile.good()) {
        getline(readfile, line);
    QString ligne;
    while(! flux.atEnd()) {
        ligne = flux.readLine();
        ++nb;
    }