Back to index

fet  5.18.0
Functions | Variables
timetable_defs.cpp File Reference
#include "timetable_defs.h"
#include <ctime>
#include <QHash>
#include <QLocale>

Go to the source code of this file.

Functions

QString protect (const QString &str)
 A function used in xml saving.
QString protect2 (const QString &str)
 A function used in html saving.
QString protect2vert (const QString &str)
 A function used in html saving.
void weight_sscanf (const QString &str, const char *fmt, double *result)
double customFETStrToDouble (const QString &str, bool *ok)
void initRandomKnuth ()
int randomKnuth1MM1 ()
int randomKnuth (int k)

Variables

bool checkForUpdates
QString internetVersion
const QString FET_VERSION = "5.18.0"
 FET version.
QString FET_LANGUAGE = "en_US"
 FET language.
QString OUTPUT_DIR
 The output directory.
bool LANGUAGE_STYLE_RIGHT_TO_LEFT
QString LANGUAGE_FOR_HTML
int TIMETABLE_HTML_LEVEL
 Timetable html css javaScript Level, by Volker Dirr.
bool PRINT_NOT_AVAILABLE_TIME_SLOTS
bool PRINT_BREAK_TIME_SLOTS
bool PRINT_ACTIVITIES_WITH_SAME_STARTING_TIME
bool DIVIDE_HTML_TIMETABLES_WITH_TIME_AXIS_BY_DAYS
QHash< QString, QString > hashSubjectIDs
QHash< QString, QString > hashActivityTagIDs
QHash< QString, QString > hashStudentIDs
QHash< QString, QString > hashTeacherIDs
QHash< QString, QString > hashRoomIDs
QHash< QString, QString > hashDayIDs
const QString XML_PARSING_LOG_FILENAME = "file_open.log"
 A log file explaining how the xml input file was parsed.
const QString PREDEFINED_DAYS_OF_THE_WEEK []
 The predefined names of the days of the week.
const QString FILE_SEP = "/"
 File and directory separator.
int XX
int YY
int ZZ

Function Documentation

double customFETStrToDouble ( const QString &  str,
bool *  ok 
)

Definition at line 181 of file timetable_defs.cpp.

{
       QLocale c(QLocale::C);

       //tricks to convert numbers like 97.123456789 to 97.123457, to CUSTOM_DOUBLE_PRECISION (6) decimal digits after decimal point
       double tmpd=c.toDouble(str, ok);
       if(ok!=0)
              if((*ok)==false)
                     return tmpd;
       QString tmps=CustomFETString::number(tmpd);
       return c.toDouble(tmps, ok);
}

Here is the call graph for this function:

void initRandomKnuth ( )

Definition at line 200 of file timetable_defs.cpp.

{
       assert(MM==2147483647);
       assert(AA==48271);
       assert(QQ==44488);
       assert(RR==3399);
       
       assert(MMM==2147483399);
       assert(MMM==MM-248);
       assert(AAA==40692);
       assert(QQQ==52774);
       assert(RRR==3791);
       
       //a few tests
       XX=123; YY=123;
       int tttt=randomKnuth1MM1();
       assert(XX==5937333);
       assert(YY==5005116);
       assert(tttt==932217);

       XX=4321; YY=54321;
       tttt=randomKnuth1MM1();
       assert(XX==208578991);
       assert(YY==62946733);
       assert(tttt==145632258);

       XX=87654321; YY=987654321;
       tttt=randomKnuth1MM1();
       assert(XX==618944401);
       assert(YY==1625301246);
       assert(tttt==1141126801);

       XX=1; YY=1;
       tttt=randomKnuth1MM1();
       assert(XX==48271);
       assert(YY==40692);
       assert(tttt==7579);

       XX=MM-1; YY=MMM-1;
       tttt=randomKnuth1MM1();
       assert(XX==2147435376);
       assert(YY==2147442707);
       assert(tttt==2147476315);

       XX=100; YY=1000;
       tttt=randomKnuth1MM1();
       assert(XX==4827100);
       assert(YY==40692000);
       assert(tttt==2111618746);
       
       //unsigned tt=unsigned(time(NULL));
       qint64 tt=qint64(time(NULL));
       
       //XX is the current time
       //XX = 1 + ( (unsigned(tt)) % (unsigned(MM-1)) );
       XX = 1 + int( tt%(qint64(MM-1)) );
       assert(XX>0);
       assert(XX<MM);

       //YY is the next random, after initializing YY with the current time
       //YY = 1 + ( (unsigned(tt)) % (unsigned(MMM-1)) );
       YY = 1 + int( tt%(qint64(MMM-1)) );
       assert(YY>0);
       assert(YY<MMM);
       YY=AAA*(YY%QQQ)-RRR*(YY/QQQ);
       if(YY<0)
              YY+=MMM;
       assert(YY>0);
       assert(YY<MMM);
       
       ZZ=XX-YY;
       if(ZZ<=0)
              ZZ+=MM-1; //-1 is not written in Knuth TAOCP vol. 2 third edition; I think it would be an improvement. (Later edit: yes, the author confirmed that).
       assert(ZZ>0);
       assert(ZZ<MM); //again, modified from Knuth TAOCP vol. 2 third edition, ZZ is strictly lower than MM (the author confirmed that, too).
}

Here is the call graph for this function:

Here is the caller graph for this function:

QString protect ( const QString &  str)

A function used in xml saving.

Definition at line 97 of file timetable_defs.cpp.

{
       QString p=str;
       p.replace("&", "&amp;");
       p.replace("\"", "&quot;");
       p.replace(">", "&gt;");
       p.replace("<", "&lt;");
       p.replace("'", "&apos;");
       return p;
}
QString protect2 ( const QString &  str)

A function used in html saving.

Definition at line 108 of file timetable_defs.cpp.

{
       QString p=str;
       p.replace("&", "&amp;");
       p.replace("\"", "&quot;");
       p.replace(">", "&gt;");
       p.replace("<", "&lt;");
       //p.replace("'", "&apos;");
       return p;
}
QString protect2vert ( const QString &  str)

A function used in html saving.

Definition at line 119 of file timetable_defs.cpp.

{
       QString p=str;
       p.replace("&", "&amp;");
       p.replace("\"", "&quot;");
       p.replace(">", "&gt;");
       p.replace("<", "&lt;");
       //p.replace("'", "&apos;");

       QString returnstring;
       for(int i=0; i<p.size();i++){
              QString a=p.at(i);
              QString b="<br />";
              returnstring.append(a);
              returnstring.append(b);
       }
       return returnstring;
}

Here is the caller graph for this function:

int randomKnuth ( int  k)

Definition at line 309 of file timetable_defs.cpp.

{
       //like in Knuth TAOCP vol.2, reject some numbers (very few), so that the distribution is perfectly uniform
       for(;;){
              int U=randomKnuth1MM1();
              if( U <= k * ((MM-1)/k) )
                     return U%k;
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

int randomKnuth1MM1 ( )

Definition at line 278 of file timetable_defs.cpp.

{
       assert(XX>0);
       assert(XX<MM);

       XX=AA*(XX%QQ)-RR*(XX/QQ);
       if(XX<0)
              XX+=MM;

       assert(XX>0);
       assert(XX<MM);

       assert(YY>0);
       assert(YY<MMM);

       YY=AAA*(YY%QQQ)-RRR*(YY/QQQ);
       if(YY<0)
              YY+=MMM;
       
       assert(YY>0);
       assert(YY<MMM);

       ZZ=XX-YY;
       if(ZZ<=0)
              ZZ+=MM-1; //-1 is not written in Knuth TAOCP vol. 2 third edition; I think it would be an improvement. (Later edit: yes, the author confirmed that).
       assert(ZZ>0);
       assert(ZZ<MM); //again, modified from Knuth TAOCP vol. 2 third edition, ZZ is strictly lower than MM (the author confirmed that, too).
       
       return ZZ;
}

Here is the caller graph for this function:

void weight_sscanf ( const QString &  str,
const char *  fmt,
double *  result 
)

Definition at line 139 of file timetable_defs.cpp.

{
       assert(QString(fmt)==QString("%lf"));

       bool ok;
       double myres=customFETStrToDouble(str, &ok);
       if(!ok)
              (*result)=-2.5; //any value that does not belong to {>=0.0 and <=100.0} or {-1.0}
                                          //not -1.0 because of modify multiple constraints min days between activities,
                                          //-1 there represents any weight
                                          //potential bug found by Volker Dirr
       else
              (*result)=myres;
}

Here is the call graph for this function:


Variable Documentation

Definition at line 30 of file timetable_defs.cpp.

Definition at line 67 of file timetable_defs.cpp.

QString FET_LANGUAGE = "en_US"

FET language.

The language.

Definition at line 42 of file timetable_defs.cpp.

const QString FET_VERSION = "5.18.0"

FET version.

The version number.

Definition at line 37 of file timetable_defs.cpp.

const QString FILE_SEP = "/"

File and directory separator.

The maximum number of time constraints.

Definition at line 95 of file timetable_defs.cpp.

QHash<QString, QString> hashActivityTagIDs

Definition at line 71 of file timetable_defs.cpp.

QHash<QString, QString> hashDayIDs

Definition at line 75 of file timetable_defs.cpp.

QHash<QString, QString> hashRoomIDs

Definition at line 74 of file timetable_defs.cpp.

QHash<QString, QString> hashStudentIDs

Definition at line 72 of file timetable_defs.cpp.

QHash<QString, QString> hashSubjectIDs

Definition at line 70 of file timetable_defs.cpp.

QHash<QString, QString> hashTeacherIDs

Definition at line 73 of file timetable_defs.cpp.

QString internetVersion

Definition at line 32 of file timetable_defs.cpp.

Definition at line 54 of file timetable_defs.cpp.

Definition at line 52 of file timetable_defs.cpp.

QString OUTPUT_DIR

The output directory.

Please be careful when editing it, because the functions add a FILE_SEP sign at the end of it and then the name of a file. If you make OUTPUT_DIR="", there will be problems.

Definition at line 50 of file timetable_defs.cpp.

const QString PREDEFINED_DAYS_OF_THE_WEEK[]
Initial value:
{"Monday", "Tuesday", "Wednesday",
       "Thursday", "Friday", "Saturday", "Sunday", "Monday2",
       "Tuesday2", "Wednesday2", "Thursday2", "Friday2", "Saturday2", "Sunday2",
       "Monday3", "Tuesday3", "Wednesday3",
       "Thursday3", "Friday3", "Saturday3", "Sunday3", "Monday4",
       "Tuesday4", "Wednesday4", "Thursday4", "Friday4", "Saturday4", "Sunday4"}

The predefined names of the days of the week.

Definition at line 85 of file timetable_defs.cpp.

Definition at line 65 of file timetable_defs.cpp.

Definition at line 63 of file timetable_defs.cpp.

Definition at line 61 of file timetable_defs.cpp.

Timetable html css javaScript Level, by Volker Dirr.

Timetable html css javaScript Level, added by Volker Dirr.

Definition at line 59 of file timetable_defs.cpp.

const QString XML_PARSING_LOG_FILENAME = "file_open.log"

A log file explaining how the xml input file was parsed.

Definition at line 80 of file timetable_defs.cpp.

int XX

Definition at line 195 of file timetable_defs.cpp.

int YY

Definition at line 196 of file timetable_defs.cpp.

int ZZ

Definition at line 197 of file timetable_defs.cpp.