Пример #1
0
		bool Save()
		{
			std::ostringstream o;

			o << "<agenda>" << std::endl;
			o << "<notes>" << std::endl;

			for (int i=0; i<(int)events.size(); i++) {
				struct agenda_t *t = events[i];

				o << "<event day=\"" << t->day << "\" month=\"" << t->month << "\" year=\"" << t->year << "\">" << std::endl;
				o << t->event << std::endl;
				o << "</event>" << std::endl;
			}

			o << "</notes>" << std::endl;
			o << "</agenda>" << std::endl;

			XmlDocument doc;

			doc.Parse(o.str().c_str());

			if (doc.Error()) {
				return false;
			}

			doc.SaveFile(_file.c_str());

			return true;
		}
Пример #2
0
void AnswerGenerator::SaveAnswer( AnswerList & answerList )
{
	XmlDocument xmlDoc;
	XmlNode * resNode = xmlDoc.AddNode( "resource" );

	int count = answerList.size();
	for( int num = 0; num < count; num++ )
	{
		AnswerData & answer = answerList[ num ];

		std::string ans = answer._answer;
		std::string ref = answer._reference;

		XmlNode * qsNode = resNode->AddNode( "question" );
		
		char buf[8]; itoa(num, buf, 10);
		qsNode->SetAttribute( "no", buf );

		XmlNode * referenceNode = qsNode->AddNode( "table" );
		referenceNode->SetText( ref.c_str(), XmlNode::NUMBER );

		XmlNode * answerNode = qsNode->AddNode( "answer" );
		answerNode->SetText( ans.c_str(), XmlNode::NUMBER );
	}

	std::string path = "./resource/ResultAnswer.xml";
	xmlDoc.SaveFile( path.c_str() );
}
Пример #3
0
void DBDictionary::Init()
{
	// 사전 초기화
	_dic.clear();

	// 사전 생성 옵션 로드
	XmlDocument xmlDoc;
	std::string path = "./resource/DBDicConfig.xml";
	xmlDoc.LoadFile( path.c_str() );

	const XmlNode * resNode = xmlDoc.GetNode( "resource" );
	std::string create = resNode->GetAttribute( "create" );

	if( create == "true" )
	{
		// 사전 생성
		CreateDBDic( resNode );

		// 사전 저장
		XmlDocument xmlDoc;
		XmlNode * resNode = xmlDoc.AddNode( "resource" );
		SaveToXML( resNode );

		std::string path = "./resource/DBDic.xml";
		xmlDoc.SaveFile( path.c_str() );
	}
	else
	{
		// 사전 로드
		XmlDocument xmlDoc;
		std::string path = "./resource/DBDic.xml";
		xmlDoc.LoadFile( path.c_str() );

		const XmlNode * resNode = xmlDoc.GetNode( "resource" );
		LoadFromXML( resNode );
	}
}