-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtestqt.cxx
49 lines (43 loc) · 1.45 KB
/
testqt.cxx
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
37
38
39
40
41
42
43
44
45
46
//-< TESTQT.CXX >----------------------------------------------------*--------*
// POST++ Version 1.0 (c) 1998 GARRET * ? *
// (Persistent Object Storage) * /\| *
// * / \ *
// Created: 16-Nov-99 K.A. Knizhnik * / [] \ *
// Last update: 16-Nov-99 K.A. Knizhnik * GARRET *
//-------------------------------------------------------------------*--------*
// Example: test for compatibility with Qt library
//-------------------------------------------------------------------*--------*
#include "storage.h"
#include "qarray.h"
USE_POST_NAMESPACE
int main()
{
storage store("testqt");
if (store.open(storage::fixed)) {
void* root = store.get_root_object();
if (root != NULL) {
QArray<char*>& text = *(QArray<char*>*)root;
for (int i = 0; text[i] != NULL; i++) {
fputs(text[i], stdout);
delete text[i];
}
delete &text;
}
int n_lines = 0;
int allocated = 8;
QArray<char*>& text = *new QArray<char*>(allocated);
char buf[256];
while (fgets(buf, sizeof buf, stdin)) {
if (n_lines+1 == allocated) {
text.resize(allocated *= 2);
}
text[n_lines] = new char[strlen(buf)+1];
strcpy(text[n_lines++], buf);
}
text[n_lines] = NULL;
store.set_root_object(&text);
store.flush();
store.close();
}
return 0;
}