コード例 #1
0
string DataDocumentManager::getlistOfTakenDocuments()
{
	ByteString bs = this->fileVariableRecord->readNext();
	string out = "Id  |     Autor    | Titulo  |  Fecha\n";

	while(!bs.isEmpty())
	{

		Document document;
		document.Hidratate(bs);

		out.append(document.getDocumentFormatedText());

		bs = this->fileVariableRecord->readNext();
	}
	return out;
}
コード例 #2
0
bool DataDocumentManager::addDocument(ByteString byteString)
{
	bool saved = false;
	int realID = this->autoIncInteger + 1;
	int documentID;
	string sid = Utility::intToString(realID);
	string did;

	Document document;
	document.Hidratate(byteString);
	document.setFakeId(realID);
	if(document.getTitle()[0] == 'T')
		documentID = this->twtautoIncInteger + 1;
	else if(document.getTitle()[0] == 'N')
		documentID = this->rssautoIncInteger + 1;
	did = Utility::intToString(documentID);
	document.setIdentificador(Utility::concat(document.getTitle(), did));

	int position = this->fileVariableRecord->addDocument(document.Serialize());
	if(position > -1)
	{
		this->autoIncInteger++;
		if(document.getTitle()[0] == 'N')
			rssautoIncInteger++;
		else if(document.getTitle()[0] == 'T')
			twtautoIncInteger++;
		ByteString idDocument;
		idDocument.insertLast(&realID, sizeof(int));
		Key* key = new Key(idDocument.toString());
		ByteString offset;
		offset.insertLast(&position, sizeof(int));
		Record* recPrincipalInd = new Record(key,&offset);
		this->principalIndex->add(recPrincipalInd);
		addIDtoFileFlags(IndexWrapper::AUTOR,idDocument.readAsInt(0));
		addIDtoFileFlags(IndexWrapper::TITULO,idDocument.readAsInt(0));
		addIDtoFileFlags(IndexWrapper::PALABRAS,idDocument.readAsInt(0));
		addIDtoFileFlags(IndexWrapper::IDENTIFICADOR,idDocument.readAsInt(0));
		addIDtoFileFlags(IndexWrapper::FECHA,idDocument.readAsInt(0));

		saved = true;
	}
	return saved;
}