#ifndef H_CORAL_XMLNS_CONVERSION_TABLE
#define H_CORAL_XMLNS_CONVERSION_TABLE
// This file is part of the Coral project.
// Please read the copyright notice in the LICENSE file.

#include <string>

/*
 * Conversion table for supporting mapping metamodel URIs to
 * the actual metamodel.
 *
 */

namespace coral {

#ifndef SWIG
	struct xmlns_conversion_entry {
		std::string xmlns;
		std::string smd_model_filename;
		std::string metamodelname;
		int version;
		int revision;
		xmlns_conversion_entry() { ; }
		~xmlns_conversion_entry() { ; }
		bool operator==(const struct xmlns_conversion_entry& t) const {
			return xmlns == t.xmlns
				&& smd_model_filename == t.smd_model_filename
				&& metamodelname == t.metamodelname
				&& version == t.version
				&& revision == t.revision;
		}
		bool operator!=(const struct xmlns_conversion_entry& t) const {
			return !(*this == t);
		}
	};

	/*
	 * Get a reverse map entry. The xmlns field
	 * must be filled in, others are discarded.
	 * Returns true on success, otherwise false
	 * and no fields are touched.
	 */
	bool getXMLNSRmap(struct xmlns_conversion_entry* fill_in);

#endif
	/*
	 * Add a reverse map entry from XML namespace string
	 * to metamodel name, version and revision
	 * e.g. http://schema.omg.org/spec/UML/1.4 => UML, 1, 4
	 * Returns true on success. Multiple insertion of same
	 * data allowed.
	 */
	bool addXMLNSRmap(const std::string& xmlns,
			  const std::string& filename,
			  const std::string& metamodelname,
			  int version,
			  int revision);

	/*
	 * Returns the size of the table
	 * Immediately afterwards, without any other xmlns operations
	 * the various xmlns_db_* functions are valid and available.
	 */
	int xmlns_db_size();
	std::string xmlns_db_xmlns(int idx);
	std::string xmlns_db_filename(int idx);
	std::string xmlns_db_metamodelname(int idx);
	int xmlns_db_version(int idx);
	int xmlns_db_revision(int idx);
}

#endif
