<commit_before>#ifndef VAST_IO_FILE_STREAM_H
#define VAST_IO_FILE_STREAM_H

#include "vast/filesystem.h"
#include "vast/io/buffered_stream.h"

namespace vast {
namespace io {

class file_input_device : public input_device
{
public:
  file_input_device(path const& filename);
  file_input_device(file::native_type handle, bool close_behavior);
  file_input_device(file_input_device&&) = default;
  file_input_device& operator=(file_input_device&&) = default;

  virtual bool read(void* data, size_t bytes, size_t* got) override;
  virtual bool skip(size_t bytes, size_t *skipped) override;

private:
  file file_;
};

/// An input stream that reads from a file.
class file_input_stream : public input_stream
{
public:
  /// Constructs a file input stream from a filename.
  /// @param filename The path to the file to read.
  /// @param block_size The number of bytes to read at once from the underlying
  ///                   buffer.
  explicit file_input_stream(path const& filename, size_t block_size = 0);

  /// Constructs a file input stream from a native file handle.
  /// @param handle The open file handle.
  /// @param close_behavior Whether to close the file upon destruction.
  /// @param block_size The number of bytes to read at once from the underlying
  ///                   buffer.
  file_input_stream(file::native_type handle, bool close_behavior,
                    size_t block_size = 0);

  file_input_stream(file_input_stream&& other) = default;
  file_input_stream& operator=(file_input_stream&& other) = default;

  bool next(void const** data, size_t* size) override;
  void rewind(size_t bytes) override;
  bool skip(size_t bytes) override;
  uint64_t bytes() const override;

private:
  file_input_device buffer_;
  buffered_input_stream buffered_stream_;
};

class file_output_device : public output_device
{
public:
  file_output_device(path const& filename);
  file_output_device(file::native_type handle, bool close_behavior);
  file_output_device(file_output_device&&) = default;
  file_output_device& operator=(file_output_device&&) = default;

  bool write(void const* data, size_t bytes, size_t* put) override;

private:
  file file_;
};

/// An output stream that writes to a file.
class file_output_stream : public output_stream
{
public:
  /// Constructs a file output stream from a filename.
  /// @param filename The path to the file to write to.
  /// @param block_size The number of bytes to write at once to the underlying
  ///                   buffer.
  file_output_stream(path const& filename, size_t block_size = 0);

  /// Constructs a file output stream from a native file handle.
  /// @param handle The open file handle.
  /// @param close_behavior Whether to close the file upon destruction.
  /// @param block_size The number of bytes to write at once to the underlying
  ///                   buffer.
  file_output_stream(file::native_type handle, bool close_behavior,
                    size_t block_size = 0);

  virtual ~file_output_stream();

  /// Flushes data to the underying output buffer.
  /// @returns `true` *iff* flushing succeeded.
  bool flush();

  bool next(void** data, size_t* size) override;
  void rewind(size_t bytes) override;
  uint64_t bytes() const override;

private:
  file_output_device buffer_;
  buffered_output_stream buffered_stream_;
};

} // namespace io
} // namespace vast

#endif
<commit_msg>Make file stream constructors explicit<commit_after>#ifndef VAST_IO_FILE_STREAM_H
#define VAST_IO_FILE_STREAM_H

#include "vast/filesystem.h"
#include "vast/io/buffered_stream.h"

namespace vast {
namespace io {

class file_input_device : public input_device
{
public:
  file_input_device(path const& filename);
  file_input_device(file::native_type handle, bool close_behavior);
  file_input_device(file_input_device&&) = default;
  file_input_device& operator=(file_input_device&&) = default;

  virtual bool read(void* data, size_t bytes, size_t* got) override;
  virtual bool skip(size_t bytes, size_t *skipped) override;

private:
  file file_;
};

/// An input stream that reads from a file.
class file_input_stream : public input_stream
{
public:
  /// Constructs a file input stream from a filename.
  /// @param filename The path to the file to read.
  /// @param block_size The number of bytes to read at once from the underlying
  ///                   buffer.
  explicit file_input_stream(path const& filename, size_t block_size = 0);

  /// Constructs a file input stream from a native file handle.
  /// @param handle The open file handle.
  /// @param close_behavior Whether to close the file upon destruction.
  /// @param block_size The number of bytes to read at once from the underlying
  ///                   buffer.
  explicit file_input_stream(file::native_type handle,
                             bool close_behavior = close_on_destruction,
                             size_t block_size = 0);

  file_input_stream(file_input_stream&& other) = default;
  file_input_stream& operator=(file_input_stream&& other) = default;

  bool next(void const** data, size_t* size) override;
  void rewind(size_t bytes) override;
  bool skip(size_t bytes) override;
  uint64_t bytes() const override;

private:
  file_input_device buffer_;
  buffered_input_stream buffered_stream_;
};

class file_output_device : public output_device
{
public:
  file_output_device(path const& filename);
  file_output_device(file::native_type handle, bool close_behavior);
  file_output_device(file_output_device&&) = default;
  file_output_device& operator=(file_output_device&&) = default;

  bool write(void const* data, size_t bytes, size_t* put) override;

private:
  file file_;
};

/// An output stream that writes to a file.
class file_output_stream : public output_stream
{
public:
  /// Constructs a file output stream from a filename.
  /// @param filename The path to the file to write to.
  /// @param block_size The number of bytes to write at once to the underlying
  ///                   buffer.
  explicit file_output_stream(path const& filename, size_t block_size = 0);

  /// Constructs a file output stream from a native file handle.
  /// @param handle The open file handle.
  /// @param close_behavior Whether to close the file upon destruction.
  /// @param block_size The number of bytes to write at once to the underlying
  ///                   buffer.
  explicit file_output_stream(file::native_type handle,
                              bool close_behavior = close_on_destruction,
                              size_t block_size = 0);

  virtual ~file_output_stream();

  /// Flushes data to the underying output buffer.
  /// @returns `true` *iff* flushing succeeded.
  bool flush();

  bool next(void** data, size_t* size) override;
  void rewind(size_t bytes) override;
  uint64_t bytes() const override;

private:
  file_output_device buffer_;
  buffered_output_stream buffered_stream_;
};

} // namespace io
} // namespace vast

#endif

{'fraction_non_alphanumeric': 0.08628127696289906, 'fraction_numerical': 0.0023008340523439745, 'mean_word_length': 3.5338983050847457, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '4119428', 'n_tokens_mistral': 2065, 'n_tokens_neox': 2003, 'n_words': 693}