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

#include <coral/coral.h>
#include <coral/lib/ref_counted.h>

#include <ostream>
#include <cstdio>
#include <exception>
#include <vector>
#include <string>

#include <coral/core/exception.h>
#include <coral/core/Project.h>

NAMESPACE_BEGIN(coral);
class EXPORTFWD_coral Element;
class EXPORTFWD_coral Language;
class EXPORTFWD_coral Project;
class EXPORTFWD_coral Collection;
	
NAMESPACE_BEGIN(io);


/*
 * Deprecated. Use loadDocument/saveDocument instead
 */
EXPORT_coral
coral::Element*
loadModel(const char* filename,
	  coral::Language* l = NULL) throw (coral::load_error, std::exception);

EXPORT_coral
void
saveModel(const char* filename,
	  coral::Element* root,
	  const char* xmi_version = "1.2")
throw (coral::save_error, std::exception);
	     


EXPORT_coral
coral::autounref<coral::Project> EXPORT_coral
loadDocument(const char* filename,
	     coral::Language* l = NULL) throw (coral::load_error, std::exception);

EXPORT_coral
coral::autounref<coral::Project> EXPORT_coral
loadDocument_str(const char* buffer) throw (coral::load_error, std::exception);

/*
 * Saves a Project with its current filename and xmi format.
 */
EXPORT_coral void saveDocument(coral::Project* st) 
     throw (coral::save_error, std::exception);

#ifndef SWIG	     
EXPORT_coral void saveDocument_raw(std::ostream& out,
				   const coral::Collection* coll,
				   const char* xmi_version)
     throw (coral::save_error, std::exception);
#endif
	     
EXPORT_coral std::string saveDocument_str(const coral::Collection* coll,
					  const char* xmi_version)
     throw (coral::save_error, std::exception);
	     
std::vector<std::string> EXPORT_coral getSupportedXMIVersions();
	     
#ifndef SWIG
class ModelStreamer {
 public:
	virtual ~ModelStreamer() throw ();
	ModelStreamer();
	virtual void saveModel(const coral::Collection*,
			       std::ostream&) = 0;
};
#endif

NAMESPACE_END();
NAMESPACE_END();

#endif
