<commit_before>/*
 * Save.cpp
 *
 *  Created on: 29.05.2017
 *      Author: Alexander
 */

#include "persistence/base/Save.hpp"

#ifdef NDEBUG
#define MSG_DEBUG(a) /**/
#else
#define MSG_DEBUG(a) std::cout << "| DEBUG    | " << a << std::endl
#endif
#define MSG_WARNING(a) std::cout << "| WARNING  | "<< a << std::endl
#define MSG_ERROR(a) std::cout << "| ERROR    | " << a << std::endl
#define MSG_FLF __FILE__ << ":" << __LINE__ << " " << __FUNCTION__ << "() "

#include <iostream>

#include "ecore/EClass.hpp"
#include "ecore/EObject.hpp"
#include "ecore/EPackage.hpp"
#include "persistence/base/SaveHandler.hpp"

using namespace persistence::base;

Save::Save ()
{
}

Save::~Save ()
{
}

bool Save::save ( const std::string &filename, std::shared_ptr<ecore::EObject> model, std::shared_ptr<ecore::EPackage> metaMetaPackage, bool xsiMode)
{
	std::shared_ptr<ecore::EClass> metaClass = model->eClass();

	MSG_DEBUG( "metaClass: " << metaClass->getName() );
	MSG_DEBUG( "metaMetaPck-NS: " << metaMetaPackage->getNsPrefix() );
	MSG_DEBUG( "metaMetaPck-Uri: " << metaMetaPackage->getNsURI() );

	m_handler->setIsXSIMode(xsiMode);
	m_handler->createRootNode( metaMetaPackage->getNsPrefix(), metaClass->getName(), metaMetaPackage->getNsURI() );
	m_handler->setRootObject( model );

	MSG_DEBUG( m_handler->extractType( model ) );

	model->save( m_handler );
	m_handler->release();

	// Call write() method in corresponding derived class
	return write( filename );
}

void Save::setTypesMap(std::map<std::string, std::shared_ptr<ecore::EObject>> typesMap)
{
	m_handler->setTypesMap(typesMap);
}<commit_msg>[persistence] set root object before createRootNode<commit_after>/*
 * Save.cpp
 *
 *  Created on: 29.05.2017
 *      Author: Alexander
 */

#include "persistence/base/Save.hpp"

#ifdef NDEBUG
#define MSG_DEBUG(a) /**/
#else
#define MSG_DEBUG(a) std::cout << "| DEBUG    | " << a << std::endl
#endif
#define MSG_WARNING(a) std::cout << "| WARNING  | "<< a << std::endl
#define MSG_ERROR(a) std::cout << "| ERROR    | " << a << std::endl
#define MSG_FLF __FILE__ << ":" << __LINE__ << " " << __FUNCTION__ << "() "

#include <iostream>

#include "ecore/EClass.hpp"
#include "ecore/EObject.hpp"
#include "ecore/EPackage.hpp"
#include "persistence/base/SaveHandler.hpp"

using namespace persistence::base;

Save::Save ()
{
}

Save::~Save ()
{
}

bool Save::save ( const std::string &filename, std::shared_ptr<ecore::EObject> model, std::shared_ptr<ecore::EPackage> metaMetaPackage, bool xsiMode)
{
	std::shared_ptr<ecore::EClass> metaClass = model->eClass();

	MSG_DEBUG( "metaClass: " << metaClass->getName() );
	MSG_DEBUG( "metaMetaPck-NS: " << metaMetaPackage->getNsPrefix() );
	MSG_DEBUG( "metaMetaPck-Uri: " << metaMetaPackage->getNsURI() );

	m_handler->setIsXSIMode(xsiMode);
	m_handler->setRootObject( model );
	m_handler->createRootNode( metaMetaPackage->getNsPrefix(), metaClass->getName(), metaMetaPackage->getNsURI() );

	MSG_DEBUG( m_handler->extractType( model ) );

	model->save( m_handler );
	m_handler->release();

	// Call write() method in corresponding derived class
	return write( filename );
}

void Save::setTypesMap(std::map<std::string, std::shared_ptr<ecore::EObject>> typesMap)
{
	m_handler->setTypesMap(typesMap);
}
{'fraction_non_alphanumeric': 0.18209876543209877, 'fraction_numerical': 0.0049382716049382715, 'mean_word_length': 5.508032128514056, 'pattern_counts': {'":': 2, '<': 83, '<?xml version=': 0, '>': 43, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '484480', 'n_tokens_mistral': 1174, 'n_tokens_neox': 1154, 'n_words': 213}