You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
87 lines
2.5 KiB
87 lines
2.5 KiB
//
|
|
// Created by ioachim on 18.05.2025.
|
|
//
|
|
|
|
#include "Document.h"
|
|
#include "User.h"
|
|
#include "Autoritate.h"
|
|
#include "Zi.h"
|
|
|
|
|
|
|
|
//Document::Document() : idDocument(""), titlu(""), Titular(nullptr), Emitator(nullptr), Continut(""), dataEmitere(new Zi(0, 0, 0)), dataExpirare(new Zi(0, 0, 0)), origineAnexa(nullptr) {}
|
|
|
|
|
|
Document& Document::operator=(const Document& secundar) {
|
|
if(this != &secundar) {
|
|
idDocument = secundar.idDocument;
|
|
titlu = secundar.titlu;
|
|
Titular = secundar.Titular;
|
|
Emitator = secundar.Emitator;
|
|
Continut = secundar.Continut;
|
|
dataEmitere = secundar.dataEmitere;
|
|
dataExpirare = secundar.dataExpirare;
|
|
}
|
|
return *this;
|
|
}
|
|
|
|
std::string Document::getID(){
|
|
return idDocument;
|
|
}
|
|
|
|
std::string Document::exportForSigning() {
|
|
std::string str = "";
|
|
std::stringstream os;
|
|
std::string emitatorStr = (Emitator != nullptr) ? Emitator->getName() : "NULL";
|
|
std::string titluarStr = (Titular != nullptr) ? Titular->getName() : "NULL";
|
|
os << "Titlu: " << titlu << "\n-----------------------------------------------\nTitular: " << titluarStr << "\nEmitator: " << emitatorStr << "\n\nContinut: \n" << Continut << "\n\nData de emitere: " << dataEmitere->day << "/" << dataEmitere->month << "/" << dataEmitere->year << "\nData de expirare: " << dataExpirare->day << "/" << dataExpirare->month << "/" << dataExpirare->year;
|
|
return os.str();
|
|
}
|
|
|
|
std::string Document::exportAnexe() {
|
|
std::stringstream os;
|
|
Anexa *ax = origineAnexa;
|
|
while (ax != nullptr) {
|
|
os << ax->exportAnexa() << std::endl;
|
|
ax = ax->getUrm();
|
|
}
|
|
return os.str();
|
|
}
|
|
|
|
std::ostream& operator<<(std::ostream& os, const Document& doc) {
|
|
Document ndoc = doc;
|
|
os << std::endl << "ID:" << ndoc.getID() << std::endl;
|
|
os << ndoc.exportForSigning();
|
|
os << std::endl << ndoc.exportAnexe();
|
|
return os;
|
|
}
|
|
|
|
Document::Document(std::string _titlu, User* _Titular, Autoritate* _Emitator, std::string _continut, Zi* _data_emitere, Zi* _data_expirare) {
|
|
if (Emitator != nullptr) {
|
|
return;
|
|
}
|
|
titlu = _titlu;
|
|
Titular = _Titular;
|
|
Emitator = _Emitator;
|
|
Continut = _continut;
|
|
dataEmitere = _data_emitere;
|
|
dataExpirare = _data_expirare;
|
|
origineAnexa = nullptr;
|
|
|
|
idDocument = hashString(exportForSigning());
|
|
}
|
|
|
|
Document::Document() {
|
|
titlu = "";
|
|
Titular = nullptr;
|
|
Emitator = nullptr;
|
|
Continut = "";
|
|
dataEmitere = nullptr;
|
|
dataExpirare = nullptr;
|
|
origineAnexa = nullptr;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|