summaryrefslogtreecommitdiff
path: root/src/misc.cc
blob: ea7257283c5055004f3cde0abf71d017d346852f (plain)
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#include <list>
#include "Handle.h"
#include "String.h"

void GeneDeroul(Handle * h, String * & l1, String * & l2) {
    int count;
    list<String> result;
    String r1, r2;
    
    count = 0;
    
    while (1) {
	(*h) >> r1;
	(*h) >> r2;
	if ((r1 == "") && (r2 == "")) break;
	result.push_back(r1);
	result.push_back(r2);
	count++;
    }
    
    l1 = new String[count + 1];
    l2 = new String[count + 1];
    
    for (int i = 0; i < count; i++) {
	r1 = result.front();
	result.pop_front();
	r2 = result.front();
	result.pop_front();
	l1[i] = r1;
	l2[i] = r2;
    }
    
    l1[count] = "";
    l2[count] = "";
}

int GeneList(Handle * h, int nbcol, String * & l) {
    int nblig;
    list<String> result;
    String r;
    bool is_null;
    
    nblig = 0;
    while (1) {
	is_null = true;
	for (int i = 0; i < nbcol; i++) {
    	    (*h) >> r;
	    result.push_back(r);
	    if (r != "") is_null = false;
	}
	if (is_null) break;
	nblig++;
    }
    
    l = new String[nbcol * nblig + 1];
    
    for (int i = 0; i < (nbcol * nblig); i++) {
	r = result.front();
	result.pop_front();
	l[i] = r;
    }
    
    l[nbcol * nblig] = "";
    
    return nblig;
}