//! \~\file piserverendpoint_p.h
//! \~\ingroup HTTP
//! \~\brief
//! \~english Shared HTTP message container types
//! \~russian Общие типы контейнеров HTTP-сообщений
/*
	PIP - Platform Independent Primitives
	Shared HTTP message container types
	Ivan Pelipenko peri4ko@yandex.ru

	This program is free software: you can redistribute it and/or modify
	it under the terms of the GNU Lesser General Public License as published by
	the Free Software Foundation, either version 3 of the License, or
	(at your option) any later version.

	This program 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 Lesser General Public License for more details.

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

#ifndef piserverendpoint_p_h
#define piserverendpoint_p_h

#include "pip_export.h"
#include "pistringlist.h"


namespace PIHTTP {


struct PIP_EXPORT ServerEndpoint {
	struct PIP_EXPORT PathElement {
		enum class Type {
			Invalid   = 0x01,
			Fixed     = 0x02,
			Arguments = 0x04,
			AnyOne    = 0x08,
			AnyPart   = 0x10,
			AnyMany   = 0x20
		};

		Type type = Type::Fixed;
		PIString source;
		PIStringList parts;
		PIMap<int, PIString> arguments;

		PathElement(const PIString & reg = {});

		bool match(const PIString & in, PIMap<PIString, PIString> & ext_args) const;
		uint priority() const;
	};

	PIStringList path;
	PIFlags<PathElement::Type> path_types;
	PIVector<PathElement> prepared_path;
	uint priority = 0;

	bool create(const PIString & p);
	bool match(const PIStringList & in_path, PIMap<PIString, PIString> & ext_args) const;

	static PIStringList splitPath(const PIString & path);
};


}; // namespace PIHTTP


#endif
