summaryrefslogtreecommitdiff
path: root/src/misc.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/misc.cc')
-rw-r--r--src/misc.cc66
1 files changed, 66 insertions, 0 deletions
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 <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;
+}