<commit_before>// Copyright (c) 2013, German Neuroinformatics Node (G-Node)
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted under the terms of the BSD License. See
// LICENSE file in the root of the Project.

/**
 * @file pandora/File.hpp
 * @brief Definition of the class file.
 */

#ifndef PAN_FILE_H_INCLUDED
#define PAN_FILE_H_INCLUDED

#include <iterator>
#include <string>
#include <H5Cpp.h>

#include <pandora/Group.hpp>

namespace pandora {
class Block;
class BlockIterator;
class Section;
class SectionIterator;

/**
 * Class that represents a pandora file.
 */
class File
{

private:

  /* prefix for IDs: currently not used */
  std::string prefix;
  /* the opened HDF5 file */
  H5::H5File  h5file;
  /* groups representing different sections of the file */
  Group       root, metadata, data;

public:

  /** Indicator for the HDF5 file being a pandora file */
  static const std::string FORMAT;
  /** The version of the pandora format */
  static const std::string VERSION;

  /** Read only file open mode */
  static const size_t READ_ONLY;
  /** Read/write file open mode */
  static const size_t READ_WRITE;
  /** Overwrite file open mode */
  static const size_t OVERWRITE;

  /**
   * Constructor that is used to open the file.
   *
   * @param name    The name of the file to open.
   * @param prefix  The prefix used for IDs.
   * @param mode    File open mode READ_ONLY, READ_WRITE or OVERWRITE.
   */
  File(std::string name, std::string prefix, int mode = READ_WRITE);

  /**
   * Copy constructor.
   *
   * @param other   The file to copy.
   */
  File(const File &other);

  /**
   * Get the number of blocks in in the file.
   *
   * @return The number of blocks.
   */
  size_t blockCount() const;

  /**
   * Check if a block exists in the file.
   *
   * @param id    The ID of the block.
   *
   * @return True if the block exists, false otherwise.
   */
  bool hasBlock(std::string id) const;

  /**
   * Read an existing block from the file.
   *
   * @param id    The ID of the block.
   *
   * @return The block with the given id.
   */
  Block getBlock(std::string id) const;

  /**
   * Read an existing with block from the file, addressed by index.
   *
   * @param index   The index of the block to read.
   *
   * @return The block at the given index.
   */
  Block getBlock(size_t index) const;

  /**
   * Create an new block, that is immediately persisted in the file.
   *
   * @param name    The name of the block.
   * @param type    The type of the block.
   *
   * @return The created block.
   */
  Block createBlock(std::string name, std::string type);

  /**
   * Delete a block from the file.
   *
   * @param id    The id of the block to delete.
   */
  void deleteBlock(std::string id);

  // @todo Iterate by name
  //std::iterator<Block> blocks() const;
  BlockIterator blocks() const;

  /**
     * Check if a section exists in the file.
     *
     * @param id    The ID of the section.
     *
     * @return True if the section exists, false otherwise.
     */
  bool hasSection(std::string id) const;

  Section getSection(std::string section_id) const;

  size_t sectionCount() const;

  SectionIterator sections() const;

  Section createSection(std::string name, std::string type);

  void deleteSection(std::string section_id);<commit_msg>documentation of Section realted methods<commit_after>// Copyright (c) 2013, German Neuroinformatics Node (G-Node)
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted under the terms of the BSD License. See
// LICENSE file in the root of the Project.

/**
 * @file pandora/File.hpp
 * @brief Definition of the class file.
 */

#ifndef PAN_FILE_H_INCLUDED
#define PAN_FILE_H_INCLUDED

#include <iterator>
#include <string>
#include <H5Cpp.h>

#include <pandora/Group.hpp>

namespace pandora {
class Block;
class BlockIterator;
class Section;
class SectionIterator;

/**
 * Class that represents a pandora file.
 */
class File
{

private:

  /* prefix for IDs: currently not used */
  std::string prefix;
  /* the opened HDF5 file */
  H5::H5File  h5file;
  /* groups representing different sections of the file */
  Group       root, metadata, data;

public:

  /** Indicator for the HDF5 file being a pandora file */
  static const std::string FORMAT;
  /** The version of the pandora format */
  static const std::string VERSION;

  /** Read only file open mode */
  static const size_t READ_ONLY;
  /** Read/write file open mode */
  static const size_t READ_WRITE;
  /** Overwrite file open mode */
  static const size_t OVERWRITE;

  /**
   * Constructor that is used to open the file.
   *
   * @param name    The name of the file to open.
   * @param prefix  The prefix used for IDs.
   * @param mode    File open mode READ_ONLY, READ_WRITE or OVERWRITE.
   */
  File(std::string name, std::string prefix, int mode = READ_WRITE);

  /**
   * Copy constructor.
   *
   * @param other   The file to copy.
   */
  File(const File &other);

  /**
   * Get the number of blocks in in the file.
   *
   * @return The number of blocks.
   */
  size_t blockCount() const;

  /**
   * Check if a block exists in the file.
   *
   * @param id    The ID of the block.
   *
   * @return True if the block exists, false otherwise.
   */
  bool hasBlock(std::string id) const;

  /**
   * Read an existing block from the file.
   *
   * @param id    The ID of the block.
   *
   * @return The block with the given id.
   */
  Block getBlock(std::string id) const;

  /**
   * Read an existing with block from the file, addressed by index.
   *
   * @param index   The index of the block to read.
   *
   * @return The block at the given index.
   */
  Block getBlock(size_t index) const;

  /**
   * Create an new block, that is immediately persisted in the file.
   *
   * @param name    The name of the block.
   * @param type    The type of the block.
   *
   * @return The created block.
   */
  Block createBlock(std::string name, std::string type);

  /**
   * Delete a block from the file.
   *
   * @param id    The id of the block to delete.
   */
  void deleteBlock(std::string id);

  // @todo Iterate by name
  //std::iterator<Block> blocks() const;
  BlockIterator blocks() const;

  /**
     * Check if a section exists in the file.
     *
     * @param id    The ID of the section.
     *
     * @return True if the section exists, false otherwise.
     */
  bool hasSection(std::string id) const;

  /**
   * Return the Section specified by the id.
   *
   * @param id  The id of the Section
   *
   * @return The section with the given id.
   */
  Section getSection(std::string section_id) const;

  /**
   * Returns the number of Sections stored in the File.
   *
   * @return size_t   The number of sections.
   */
  size_t sectionCount() const;

  /**
   * Returns a SectionIterator instance.
   *
   * @returns an Instance of SectionIterator.
   */
  SectionIterator sections() const;

  /**
   * Creates a new Section with a given name and type. Both must not be empty.
   *
   * @param std::string the given name of the section.
   * @param std::string the type of the section.
   *
   * @return   the created Section.
   */
  Section createSection(std::string name, std::string type);

  /**
   * Deletes the Section that is specified with the id.
   */
  void deleteSection(std::string section_id);
{'fraction_non_alphanumeric': 0.10211173483025929, 'fraction_numerical': 0.002673082063619353, 'mean_word_length': 2.6699362432564984, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, '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': '4298867', 'n_tokens_mistral': 2330, 'n_tokens_neox': 2267, 'n_words': 915}