<commit_before>/*! @file single_format.h
 *  @brief Single number format.
 *  @author <NAME> <<EMAIL>>
 *  @version 1.0
 *
 *  @section Notes
 *  This code partially conforms to <a href="http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml">Google C++ Style Guide</a>.
 *
 *  @section Copyright
 *  Copyright 2013 Samsung R&D Institute Russia
 */

#ifndef SRC_FORMATS_SINGLE_FORMAT_H_
#define SRC_FORMATS_SINGLE_FORMAT_H_

#include <stdexcept>
#include <tuple>
#include "src/buffers_base.h"

namespace SoundFeatureExtraction {
namespace Formats {

template<uint8_t L, typename F = float>
struct FixedArray {
  static_assert(std::is_arithmetic<F>(), "F must be an arithmetic type");
  F Data[L];

  F& operator[](int index) {
    if (index < 0 || index > L - 1) {
      throw std::out_of_range("index");
    }
    return Data[index];
  }

  F operator[](int index) const {
    if (index < 0 || index > L - 1) {
      throw std::out_of_range("index");
    }
    return Data[index];
  }

  bool operator!=(const FixedArray& other) {
    for (int i = 0; i < L; i++) {
      if (Data[i] != other[i]) {
        return true;
      }
    }
    return false;
  }
};

}  // namespace Formats
}  // namespace SoundFeatureExtraction

namespace std {
  template<uint8_t L, typename F>
  inline string to_string(
      const SoundFeatureExtraction::Formats::FixedArray<L, F>& __val) {
    std::string res("[");
    for (int i = 0; i < L; i++) {
      res += std::to_string(__val[i]) + ",\t";
    }
    res = res.substr(0, res.size() - 2);
    res += "]";
    return std::move(res);
  }

  template<size_t index, typename... Args>
  inline void to_string(int realIndex,
                        const std::tuple<Args...>& __val,
                        std::string* result) {
    if (realIndex == index) {
      *result += std::to_string(std::get<index>(__val)) + ",\t";
      to_string<index + 1 < sizeof...(Args)? index + 1 : 0>(index + 1,
                                                            __val, result);
    }
  }

  template<typename... Args>
  inline string to_string(const std::tuple<Args...>& __val) {
    if (sizeof...(Args) > 0) {
      std::string res("[");
      to_string<0>(0, __val, &res);
      res = res.substr(0, res.size() - 2);
      res += "]";
      return std::move(res);
    }
    return "[]";
  }
}  // namespace std

namespace SoundFeatureExtraction {
namespace Formats {

template<class T>
class SingleFormat : public BufferFormatBase<T> {
 public:
  SingleFormat() noexcept {
  }

  SingleFormat(const SingleFormat& other UNUSED) noexcept {
  }

  virtual const std::string& Id() const noexcept {
    static const std::string id("Number");
    return id;
  }<commit_msg>Better single format id<commit_after>/*! @file single_format.h
 *  @brief Single number format.
 *  @author <NAME> <<EMAIL>>
 *  @version 1.0
 *
 *  @section Notes
 *  This code partially conforms to <a href="http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml">Google C++ Style Guide</a>.
 *
 *  @section Copyright
 *  Copyright 2013 Samsung R&D Institute Russia
 */

#ifndef SRC_FORMATS_SINGLE_FORMAT_H_
#define SRC_FORMATS_SINGLE_FORMAT_H_

#include <stdexcept>
#include <tuple>
#include "src/buffers_base.h"

namespace SoundFeatureExtraction {
namespace Formats {

template<uint8_t L, typename F = float>
struct FixedArray {
  static_assert(std::is_arithmetic<F>(), "F must be an arithmetic type");
  F Data[L];

  F& operator[](int index) {
    if (index < 0 || index > L - 1) {
      throw std::out_of_range("index");
    }
    return Data[index];
  }

  F operator[](int index) const {
    if (index < 0 || index > L - 1) {
      throw std::out_of_range("index");
    }
    return Data[index];
  }

  bool operator!=(const FixedArray& other) {
    for (int i = 0; i < L; i++) {
      if (Data[i] != other[i]) {
        return true;
      }
    }
    return false;
  }
};

}  // namespace Formats
}  // namespace SoundFeatureExtraction

namespace std {
  template<uint8_t L, typename F>
  inline string to_string(
      const SoundFeatureExtraction::Formats::FixedArray<L, F>& __val) {
    std::string res("[");
    for (int i = 0; i < L; i++) {
      res += std::to_string(__val[i]) + ",\t";
    }
    res = res.substr(0, res.size() - 2);
    res += "]";
    return std::move(res);
  }

  template<size_t index, typename... Args>
  inline void to_string(int realIndex,
                        const std::tuple<Args...>& __val,
                        std::string* result) {
    if (realIndex == index) {
      *result += std::to_string(std::get<index>(__val)) + ",\t";
      to_string<index + 1 < sizeof...(Args)? index + 1 : 0>(index + 1,
                                                            __val, result);
    }
  }

  template<typename... Args>
  inline string to_string(const std::tuple<Args...>& __val) {
    if (sizeof...(Args) > 0) {
      std::string res("[");
      to_string<0>(0, __val, &res);
      res = res.substr(0, res.size() - 2);
      res += "]";
      return std::move(res);
    }
    return "[]";
  }
}  // namespace std

namespace SoundFeatureExtraction {
namespace Formats {

template<class T>
class SingleFormat : public BufferFormatBase<T> {
 public:
  SingleFormat() noexcept {
  }

  SingleFormat(const SingleFormat& other UNUSED) noexcept {
  }

  virtual const std::string& Id() const noexcept {
    static const std::string id(typeid(T).name());
    return id;
  }
{'fraction_non_alphanumeric': 0.15437108078199926, 'fraction_numerical': 0.009221689413500553, 'mean_word_length': 2.691626957113683, 'pattern_counts': {'":': 0, '<': 53, '<?xml version=': 0, '>': 49, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1525166', 'n_tokens_mistral': 1872, 'n_tokens_neox': 1803, 'n_words': 455}