<commit_before>/*
  This file is part of Ingen.
  Copyright 2007-2017 <NAME> <http://drobilla.net/>

  Ingen is free software: you can redistribute it and/or modify it under the
  terms of the GNU Affero General Public License as published by the Free
  Software Foundation, either version 3 of the License, or any later version.

  Ingen 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 Affero General Public License for details.

  You should have received a copy of the GNU Affero General Public License
  along with Ingen.  If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef INGEN_PROPERTIES_HPP
#define INGEN_PROPERTIES_HPP

#include "ingen/Atom.hpp"
#include "ingen/URI.hpp"
#include "ingen/URIs.hpp"

#include <initializer_list>
#include <map>
#include <utility>

namespace ingen {

/** A property value (an Atom with a context). */
class Property : public Atom {
public:
	enum class Graph {
		DEFAULT,  ///< Default context for "universal" properties
		EXTERNAL, ///< Externally visible graph properties
		INTERNAL  ///< Internally visible graph properties
	};

	Property(const Atom& atom, Graph ctx=Graph::DEFAULT)
		: Atom(atom)
		, _ctx(ctx)
	{}

	Property(const URIs::Quark& quark, Graph ctx=Graph::DEFAULT)
		: Atom(quark.urid_atom())
		, _ctx(ctx)
	{}

	Graph context() const        { return _ctx; }
	void  set_context(Graph ctx) { _ctx = ctx; }

private:
	Graph _ctx;
};

class Properties : public std::multimap<URI, Property> {
public:
	using Graph = Property::Graph;

	Properties() = default;
	Properties(const Properties& copy) = default;

	Properties(std::initializer_list<value_type> l)
		: std::multimap<URI, Property>(l)
	{}

	void put(const URI&  key,
	         const Atom& value,
	         Graph       ctx = Graph::DEFAULT) {
		emplace(key, Property(value, ctx));
	}

	void put(const URI&         key,
	         const URIs::Quark& value,
	         Graph              ctx = Graph::DEFAULT) {
		emplace(key, Property(value, ctx));
	}

	bool contains(const URI& key, const Atom& value) {
		for (const_iterator i = find(key); i != end() && i->first == key; ++i) {
			if (i->second == value) {
				return true;
			}
		}
		return false;
	}
};

} // namespace ingen<commit_msg>Fully declare special member functions<commit_after>/*
  This file is part of Ingen.
  Copyright 2007-2017 <NAME> <http://drobilla.net/>

  Ingen is free software: you can redistribute it and/or modify it under the
  terms of the GNU Affero General Public License as published by the Free
  Software Foundation, either version 3 of the License, or any later version.

  Ingen 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 Affero General Public License for details.

  You should have received a copy of the GNU Affero General Public License
  along with Ingen.  If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef INGEN_PROPERTIES_HPP
#define INGEN_PROPERTIES_HPP

#include "ingen/Atom.hpp"
#include "ingen/URI.hpp"
#include "ingen/URIs.hpp"

#include <initializer_list>
#include <map>
#include <utility>

namespace ingen {

/** A property value (an Atom with a context). */
class Property : public Atom {
public:
	enum class Graph {
		DEFAULT,  ///< Default context for "universal" properties
		EXTERNAL, ///< Externally visible graph properties
		INTERNAL  ///< Internally visible graph properties
	};

	Property(const Atom& atom, Graph ctx=Graph::DEFAULT)
		: Atom(atom)
		, _ctx(ctx)
	{}

	Property(const URIs::Quark& quark, Graph ctx=Graph::DEFAULT)
		: Atom(quark.urid_atom())
		, _ctx(ctx)
	{}

	Graph context() const        { return _ctx; }
	void  set_context(Graph ctx) { _ctx = ctx; }

private:
	Graph _ctx;
};

class Properties : public std::multimap<URI, Property> {
public:
	using Graph = Property::Graph;

	Properties() = default;

	Properties(const Properties&) = default;
	Properties& operator=(const Properties&) = default;

	Properties(Properties&&) = default;
	Properties& operator=(Properties&&) = default;

	Properties(std::initializer_list<value_type> l)
		: std::multimap<URI, Property>(l)
	{}

	void put(const URI&  key,
	         const Atom& value,
	         Graph       ctx = Graph::DEFAULT) {
		emplace(key, Property(value, ctx));
	}

	void put(const URI&         key,
	         const URIs::Quark& value,
	         Graph              ctx = Graph::DEFAULT) {
		emplace(key, Property(value, ctx));
	}

	bool contains(const URI& key, const Atom& value) {
		for (const_iterator i = find(key); i != end() && i->first == key; ++i) {
			if (i->second == value) {
				return true;
			}
		}
		return false;
	}
};

} // namespace ingen
{'fraction_non_alphanumeric': 0.11371168185584093, 'fraction_numerical': 0.003728251864125932, 'mean_word_length': 3.5513666352497646, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '2985225', 'n_tokens_mistral': 1588, 'n_tokens_neox': 1487, 'n_words': 517}