<commit_before>#pragma once

#include <AttributeType.h>
#include <Foreach.h>

#include <map>

#include <Serializer.h>
#include <DeSerializer.h>

class EventType{
  public:
    using KeyType = id::attribute::ID;
    using ValueType = AttributeType;
  private:
    using StorageType = std::map<KeyType, ValueType>;
    using PairType    = StorageType::value_type;
    StorageType mStorage;

    class Parser{
      private:
        StorageType& mStorage;
      public:
        Parser(StorageType& storage);
        template<typename Attr>
        void operator()(Attr attr){
          AttributeType aT(attr);
          mStorage.insert(PairType(aT.id(), aT));
        }
    };

  public:
    class const_iterator : public StorageType::const_iterator {
      public:
        const_iterator(StorageType::const_iterator i);
        const ValueType& operator*() const;
    };

    const_iterator begin() const;
    const_iterator end() const;

    EventType() = default;

    template<typename Event>
    EventType(const Event& e){
      Parser p(mStorage);
      foreach<typename Event::AttributeList>(p);
    }

    bool add(const AttributeType& aT) {
      if(mStorage.count(aT.id()))
        return false;
      mStorage.insert(std::make_pair(aT.id(), aT));
      return true;
    }

    const AttributeType* attribute(KeyType key) const;
    
    bool operator==(const EventType& b) const;
    bool operator!=(const EventType& b) const { return !(*this==b); }

    uint8_t length() const;

    std::size_t size() const throw();

    template<typename PB> friend DeSerializer<PB>& operator>>(DeSerializer<PB>&, EventType&);
};

template<typename PB>
Serializer<PB>& operator<<(Serializer<PB>& s, const EventType& t){
  s << t.length();
  for(const auto& a : t)
    s << a;
  return s;
}
<commit_msg>EventType: Fix templated Event constructor<commit_after>#pragma once

#include <AttributeType.h>
#include <Event.h>
#include <Foreach.h>

#include <map>

#include <Serializer.h>
#include <DeSerializer.h>

class EventType{
  public:
    using KeyType = id::attribute::ID;
    using ValueType = AttributeType;
  private:
    using StorageType = std::map<KeyType, ValueType>;
    using PairType    = StorageType::value_type;
    StorageType mStorage;

    class Parser{
      private:
        StorageType& mStorage;
      public:
        Parser(StorageType& storage);
        template<typename Attr>
        void operator()(Attr attr){
          AttributeType aT(attr);
          mStorage.insert(PairType(aT.id(), aT));
        }
    };

  public:
    class const_iterator : public StorageType::const_iterator {
      public:
        const_iterator(StorageType::const_iterator i);
        const ValueType& operator*() const;
    };

    const_iterator begin() const;
    const_iterator end() const;

    EventType() = default;

    template<Endianess end=hostEndianess, typename... Attributes>
    EventType(const Event<end, Attributes...>& e){
      Parser p(mStorage);
      foreach<typename Event<end, Attributes...>::AttributeList>(p);
    }

    bool add(const AttributeType& aT) {
      if(mStorage.count(aT.id()))
        return false;
      mStorage.insert(std::make_pair(aT.id(), aT));
      return true;
    }

    const AttributeType* attribute(KeyType key) const;
    
    bool operator==(const EventType& b) const;
    bool operator!=(const EventType& b) const { return !(*this==b); }

    uint8_t length() const;

    std::size_t size() const throw();

    template<typename PB> friend DeSerializer<PB>& operator>>(DeSerializer<PB>&, EventType&);
};

template<typename PB>
Serializer<PB>& operator<<(Serializer<PB>& s, const EventType& t){
  s << t.length();
  for(const auto& a : t)
    s << a;
  return s;
}

{'fraction_non_alphanumeric': 0.130212536992198, 'fraction_numerical': 0.0005380683346785041, 'mean_word_length': 3.2202043132803633, 'pattern_counts': {'":': 0, '<': 48, '<?xml version=': 0, '>': 40, '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': '308693', 'n_tokens_mistral': 1167, 'n_tokens_neox': 1136, 'n_words': 282}