From 8346d0774d2d1e076038db27f65f1d082a460f16 Mon Sep 17 00:00:00 2001 From: Pixel Date: Thu, 20 Sep 2001 23:27:01 +0000 Subject: Initial revision --- src/misc.cc | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 src/misc.cc (limited to 'src/misc.cc') diff --git a/src/misc.cc b/src/misc.cc new file mode 100644 index 0000000..ea72572 --- /dev/null +++ b/src/misc.cc @@ -0,0 +1,66 @@ +#include +#include "Handle.h" +#include "String.h" + +void GeneDeroul(Handle * h, String * & l1, String * & l2) { + int count; + list 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 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; +} -- cgit v1.2.3