<commit_before>/** \file    File.h
 *  \brief   Declaration of class File.
 *  \author  Dr. <NAME>
 */

/*
 *  Copyright 2005-2008 Project iVia.
 *  Copyright 2005-2008 The Regents of The University of California.
 *  Copyright 2015-2018 Library of the University of Tübingen
 *
 *  This file is part of the libiViaCore package.
 *
 *  The libiViaCore package is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Lesser General Public License as published
 *  by the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  libiViaCore is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public License
 *  along with libiViaCore; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
#pragma once


#include <stdexcept>
#include <string>
#include <cstdio>
#include "Compiler.h"


class File {
public:
    template<typename ArgType> struct SingleArgManipulator {
        File &(*func_)(File &file, ArgType arg);
        ArgType arg_;
    public:
        SingleArgManipulator(File &(*func)(File &file, ArgType arg), ArgType arg): func_(func), arg_(arg) { }
    };

    enum ThrowOnOpenBehaviour { THROW_ON_ERROR, DO_NOT_THROW_ON_ERROR };
private:
    enum OpenMode { READING, WRITING, READING_AND_WRITING };
private:
    std::string filename_;
    char buffer_[BUFSIZ];
    char *buffer_ptr_;
    size_t read_count_;
    FILE *file_;
    unsigned pushed_back_count_;
    char pushed_back_chars_[2];
    int precision_;
    OpenMode open_mode_;
public:
    /** \brief  Creates and initalises a File object.<commit_msg>Increased I/O buffer for read and write by a factor of 10.<commit_after>/** \file    File.h
 *  \brief   Declaration of class File.
 *  \author  Dr. <NAME>
 */

/*
 *  Copyright 2005-2008 Project iVia.
 *  Copyright 2005-2008 The Regents of The University of California.
 *  Copyright 2015-2019 Library of the University of Tübingen
 *
 *  This file is part of the libiViaCore package.
 *
 *  The libiViaCore package is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Lesser General Public License as published
 *  by the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  libiViaCore is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public License
 *  along with libiViaCore; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
#pragma once


#include <stdexcept>
#include <string>
#include "Compiler.h"


class File {
public:
    template<typename ArgType> struct SingleArgManipulator {
        File &(*func_)(File &file, ArgType arg);
        ArgType arg_;
    public:
        SingleArgManipulator(File &(*func)(File &file, ArgType arg), ArgType arg): func_(func), arg_(arg) { }
    };

    enum ThrowOnOpenBehaviour { THROW_ON_ERROR, DO_NOT_THROW_ON_ERROR };
private:
    enum OpenMode { READING, WRITING, READING_AND_WRITING };
private:
    std::string filename_;
    char buffer_[81920];
    char *buffer_ptr_;
    size_t read_count_;
    FILE *file_;
    unsigned pushed_back_count_;
    char pushed_back_chars_[2];
    int precision_;
    OpenMode open_mode_;
public:
    /** \brief  Creates and initalises a File object.
{'fraction_non_alphanumeric': 0.07833505687693898, 'fraction_numerical': 0.02249224405377456, 'mean_word_length': 3.488399071925754, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 12, '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': '773645', 'n_tokens_mistral': 1215, 'n_tokens_neox': 1139, 'n_words': 460}