<commit_before>/* 
 * File:   date_field.cpp
 * Author: mexus
 * 
 * Created on January 30, 2014, 3:39 PM
 */

#include "date_field.h"

logxx::Log DateField::cLog(Field::cLog, "DateField");


DateField::DateField() : Field() {
}

DateField::~DateField() {
}

bool DateField::CheckValue() const {
        S_LOG("CheckValue");
        if (value.size() != 8){
                log(logxx::error) << "Date should constists of 8 symbols, but in contains " << value.size() << logxx::endl;
                return false;
        }
        for (size_t i = 0; i < 8; ++i){
                if (value[i] < 0 || value[0] > 9){
                        log(logxx::error) << "Detected non-numeric value at " << i + 1 << ": [" << value[i] << "]" << logxx::endl;
                        return false;
                }
        }
        return true;
}

void DateField::ProcessValue() {
        Field::ProcessValue();
        if (CheckValue())
                date = value.substr(0, 4) + "-" + value.substr(4, 2) + "-" + value.substr(6, 2);
        else
                value.clear();
}

<commit_msg>Added call to parent ProcessValue()<commit_after>/* 
 * File:   date_field.cpp
 * Author: mexus
 * 
 * Created on January 30, 2014, 3:39 PM
 */

#include "date_field.h"

logxx::Log DateField::cLog(Field::cLog, "DateField");


DateField::DateField() : Field() {
}

DateField::~DateField() {
}

bool DateField::CheckValue() const {
        S_LOG("CheckValue");
        if (value.size() != 8){
                log(logxx::error) << "Date should constists of 8 symbols, but in contains " << value.size() << logxx::endl;
                return false;
        }
        for (size_t i = 0; i < 8; ++i){
                if (value[i] < '0' || value[0] > '9'){
                        log(logxx::error) << "Detected non-numeric value at " << i + 1 << ": [" << value[i] << "]" << logxx::endl;
                        return false;
                }
        }
        return true;
}

void DateField::ProcessValue() {
        Field::ProcessValue();
        if (CheckValue())
                date = value.substr(0, 4) + "-" + value.substr(4, 2) + "-" + value.substr(6, 2);
        else
                value.clear();
}


{'fraction_non_alphanumeric': 0.1749084249084249, 'fraction_numerical': 0.021062271062271064, 'mean_word_length': 1.9250334672021419, 'pattern_counts': {'":': 2, '<': 43, '<?xml version=': 0, '>': 5, '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': '4122619', 'n_tokens_mistral': 751, 'n_tokens_neox': 691, 'n_words': 164}