#ifndef MATCHMAKING_METADATA_HELPER_H_
#define MATCHMAKING_METADATA_HELPER_H_

#pragma once
#include <StovePCMatchmakingDefine.h>

#include <map>
#include <string>

// 콜백 포인터 => 메타 데이터 변환 객체
class MetadataHelper
{
	using ItemMap = std::map<std::wstring, std::wstring>;

public:
	MetadataHelper()
	{
	}
	MetadataHelper(const StovePCMatchmakingMetadata* metadataArray, int32_t count)
	{
		if (nullptr == metadataArray)
			return;

		for (int32_t i = 0; i < count; ++i)
		{
			_items.insert(std::pair<std::wstring, std::wstring>(metadataArray[i].key, metadataArray[i].value));
		}
	}
	~MetadataHelper()
	{
	}

	bool keyexist(const std::wstring& key)
	{
		ItemMap::iterator iter = _items.find(key);
		if (iter != _items.end())
		{
			return true;
		}
		return false;
	}

	ItemMap::iterator find(const std::wstring& key)
	{
		return _items.find(key);
	}

	ItemMap::const_iterator find(const std::wstring& key) const
	{
		return _items.find(key);
	}

	bool empty() const
	{
		return _items.empty();
	}

	std::size_t size() const
	{
		return _items.size();
	}

	std::wstring& operator[](const std::wstring& key)
	{
		return _items[key];
	}

	const ItemMap::const_iterator cbegin() const { return _items.cbegin(); }
	const ItemMap::const_iterator cend() const { return _items.cend(); }

	const ItemMap::const_reverse_iterator crbegin() const { return _items.crbegin(); }
	const ItemMap::const_reverse_iterator crend() const { return _items.crend(); }

	ItemMap::iterator begin() { return _items.begin(); }
	ItemMap::iterator end() { return _items.end(); }

	ItemMap::reverse_iterator rbegin() { return _items.rbegin(); }
	ItemMap::reverse_iterator rend() { return _items.rend(); }

private:
	ItemMap _items;
};

#endif //MATCHMAKING_METADATA_HELPER_H_