<commit_before>#include "RectangleAnnotation.h"

/**
 * @brief RectangleAnnotation::RectangleAnnotation creates a new RectangleAnnotation with ID and type
 * @param id annotation ID
 * @param type annotation type
 */
RectangleAnnotation::RectangleAnnotation(const QString& id, const QString& type) : Annotation(id, type) {

}

/**
 * @brief override the operator <<
 * @param out - the datastream
 * @param annotation data to write
 * @return out - the data stream after write
 */
QDataStream& operator<<(QDataStream& out, const RectangleAnnotation& annotation){
    annotation.toStream(out);
    return out;
}

/**
 * @brief override the operator >>
 * @param out - the datastream
 * @param annotation save new annotation
 * @return out - the data stream after read
 */
QDataStream& operator>>(QDataStream& in, RectangleAnnotation& annotation) {
    annotation.fromStream(in);
    return in;
}

/**
 * @brief calls the << operator
 * @param in - the data stream
 */
void RectangleAnnotation::toStream(QDataStream& out) const {
    out << this->mId << this->x() << this->y() << this->width()
        << this->height() << this->mType;
}

/**
 * @brief calls the >> operator
 * @param out - the data stream
 */
void RectangleAnnotation::fromStream(QDataStream& in) {
    double x, y, width, height;
    in >> this->mId >> x >> y >> width >> height >> this->mType;

    //set coordinates and size
    this->setX((int)ceil(x));
    this->setY((int)ceil(y));
    this->setWidth((int)floor(width));
    this->setHeight((int)floor(height));
}<commit_msg>optimize RectangleAnnotation : toStream & fromStream<commit_after>#include "RectangleAnnotation.h"

/**
 * @brief RectangleAnnotation::RectangleAnnotation creates a new RectangleAnnotation with ID and type
 * @param id annotation ID
 * @param type annotation type
 */
RectangleAnnotation::RectangleAnnotation(const QString& id, const QString& type) : Annotation(id, type) {

}

/**
 * @brief override the operator <<
 * @param out - the datastream
 * @param annotation data to write
 * @return out - the data stream after write
 */
QDataStream& operator<<(QDataStream& out, const RectangleAnnotation& annotation){
    annotation.toStream(out);
    return out;
}

/**
 * @brief override the operator >>
 * @param out - the datastream
 * @param annotation save new annotation
 * @return out - the data stream after read
 */
QDataStream& operator>>(QDataStream& in, RectangleAnnotation& annotation) {
    annotation.fromStream(in);
    return in;
}

/**
 * @brief calls the << operator
 * @param in - the data stream
 */
void RectangleAnnotation::toStream(QDataStream& out) const {
    out << *(Annotation*)this;      //write ID + type
    out << *(QRect*)this;            //write coordinates
}

/**
 * @brief calls the >> operator
 * @param out - the data stream
 */
void RectangleAnnotation::fromStream(QDataStream& in) {
    in >> *(Annotation*)this;
    in >> *(QRect*)this;
}
{'fraction_non_alphanumeric': 0.13577291381668946, 'fraction_numerical': 0.0, 'mean_word_length': 4.008561643835616, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 43, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7036355', 'n_tokens_mistral': 860, 'n_tokens_neox': 839, 'n_words': 263}