-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdemo.cc
36 lines (28 loc) · 828 Bytes
/
demo.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include <parser_Exemplo2.h>
#include <iostream>
#include <fstream>
using namespace std;
int main(int argc, char * argv[]) {
if (argc < 2) {
cerr << "Uso: " << argv[0] << " arquivo_codificado" << endl;
return 0;
}
// cria o decodificador
ifstream arq(argv[1]);
if (! arq.is_open()) {
perror("Ao abrir o arquivo");
return errno;
}
TAlgo::DerDeserializer decoder(arq);
// tenta decodificar uma estrutura de dados
auto other = decoder.deserialize();
arq.close();
cout << endl;
if (other) {
cout << "Estrutura de dados obtida da decodificação DER:" << endl;
other->show();
} else cerr << "Erro: não consegui decodificar a estrutura de dados ..." << endl;
// devem-se destruir explicitamente as estruturas de dados obtidas
// do decodificador
delete other;
}