Logo Search packages:      
Sourcecode: kbruch version File versions  Download package

QTextStream & task::display ( QTextStream &  str )

display the whole task, mainly for debug

just outputs the whole given task to stdout; for debugging

Definition at line 178 of file task.cpp.

References op_vector, and ratio_vector.

{
#ifdef DEBUG
    kDebug() << "task::display()";
#endif

    /* this is our pointer on the ratio_vector, set it to the beginning */
    RatioArray::iterator ratio_pointer = ratio_vector.begin();

    /* this is our pointer on the op_vector, set it to the beginning */
    ShortArray::iterator op_pointer = op_vector.begin();

    /* we need this array to look up the fitting chars for the operations */
    const char a[] = "+-*/";

    /* check, if a qSetFieldWidth() was given to the stream */
    int weite = str.fieldWidth();
    int pweite = weite;
    str << qSetFieldWidth (0);

    /* check, if ratio number and operation number fit together */
    if (ratio_vector.size() != op_vector.size() + 1) {
        kDebug() << "Number of ratios and operations do not fit.";
        return str;
    }

    while (pweite-- > 0)
        str << " ";

    /* display all numerators */
    for (ratio_pointer = ratio_vector.begin();
            ratio_pointer != ratio_vector.end(); ++ratio_pointer) {
        str << qSetFieldWidth (5) << ratio_pointer->numerator() << "   ";
    }
    str << endl;

    pweite = weite;
    while (pweite-- > 0)
        str << " ";

    /* display all operations */
    for (op_pointer = op_vector.begin();
            op_pointer != op_vector.end(); ++op_pointer) {
        str << " ----- " << a[*op_pointer];
    }
    str << " ----- = " << endl;

    pweite = weite;
    while (pweite-- > 0)
        str << " ";

    /* display all denominators */
    for (ratio_pointer = ratio_vector.begin();
            ratio_pointer != ratio_vector.end(); ++ratio_pointer) {
        if (ratio_pointer == ratio_vector.end() - 1)
            return str << qSetFieldWidth (5) << ratio_pointer->denominator() << "   ";
        str << qSetFieldWidth (5) << ratio_pointer->denominator() << "   ";
    }
    return str;
}

Generated by  Doxygen 1.6.0   Back to index