[1860] | 1 | // standard headers
|
---|
[8187] | 2 | #if defined(GSDL_USE_STL_H)
|
---|
[1860] | 3 | #include <iostream.h>
|
---|
| 4 | #include <fstream.h>
|
---|
[8187] | 5 | #include <vector.h>
|
---|
| 6 | #else
|
---|
| 7 | #include <iostream>
|
---|
| 8 | #include <fstream>
|
---|
| 9 | #include <vector>
|
---|
| 10 | #endif
|
---|
[1860] | 11 |
|
---|
| 12 | // protocol headers
|
---|
| 13 | #include "corbaiface.h"
|
---|
| 14 | using namespace gsdlInterface;
|
---|
| 15 |
|
---|
| 16 | // greenstone headers
|
---|
| 17 | #include "corbaconv_text_t.h"
|
---|
| 18 |
|
---|
| 19 | //local headers
|
---|
| 20 | #include "corbatext_t.h"
|
---|
| 21 |
|
---|
| 22 | void corbatext_fillChar(corbatext_t *t, char *text)
|
---|
| 23 | {
|
---|
| 24 | unsigned int i;
|
---|
| 25 |
|
---|
| 26 | t->text.length(0);
|
---|
| 27 | if (text == NULL)
|
---|
| 28 | {
|
---|
| 29 | return;
|
---|
| 30 | }
|
---|
| 31 | for (i = 0; i < strlen(text); i ++)
|
---|
| 32 | {
|
---|
| 33 | t->text[i] = text[i];
|
---|
| 34 | }
|
---|
| 35 | t->encoding = 0;
|
---|
| 36 | }
|
---|
| 37 |
|
---|
| 38 | void corbatext_usvector(corbatext_t t, usvector& us)
|
---|
| 39 | {
|
---|
| 40 | unsigned int i;
|
---|
| 41 |
|
---|
| 42 | for (i = 0; i < t.text.length(); i ++)
|
---|
| 43 | {
|
---|
| 44 | us.push_back(t.text[i]);
|
---|
| 45 | }
|
---|
| 46 | }
|
---|
| 47 |
|
---|
| 48 | char *corbatext_string(corbatext_t t)
|
---|
| 49 | {
|
---|
| 50 | char *lcopy;
|
---|
| 51 | unsigned int i;
|
---|
| 52 | lcopy = (char *) malloc(t.text.length() + 1);
|
---|
| 53 | for (i = 0; i < t.text.length(); i ++)
|
---|
| 54 | {
|
---|
| 55 | lcopy[i] = (char) t.text[i];
|
---|
| 56 | }
|
---|
| 57 | lcopy[i] = '\0';
|
---|
| 58 | return lcopy;
|
---|
| 59 | }
|
---|
| 60 |
|
---|
| 61 | corbatext_t_var corbatext_corbatext(text_t t)
|
---|
| 62 | { corbatext_t_var ct;
|
---|
| 63 | // usString_var us;
|
---|
| 64 |
|
---|
| 65 | // cout << "Making text\n";
|
---|
| 66 | ct = new corbatext_t;
|
---|
| 67 | // ct->text.length(20);
|
---|
| 68 | // us = new usString(20);
|
---|
| 69 | // cout << ct->text.length() << endl;
|
---|
| 70 | // cout << ct->text.maximum() << endl;
|
---|
| 71 | corbaconv_text_t::fillUsString(t,&ct->text);
|
---|
| 72 | //t.fillUsString(us);
|
---|
| 73 | // delete us;
|
---|
| 74 | // cout << "Encoding text\n";
|
---|
| 75 | ct->encoding = 0;
|
---|
| 76 | // cout << "Encoding text\n";
|
---|
| 77 | return ct;
|
---|
| 78 | }
|
---|
| 79 |
|
---|
| 80 | int corbatext_corbatext(text_t t, corbatext_t_var ct)
|
---|
| 81 | {
|
---|
| 82 | cout << "A" << endl;
|
---|
| 83 | corbaconv_text_t::fillUsString(t,&ct->text);
|
---|
| 84 | cout << "B" << endl;
|
---|
| 85 | ct->encoding = 0;
|
---|
| 86 | cout << "C" << endl;
|
---|
| 87 | }
|
---|
| 88 |
|
---|
| 89 | void corbatext_corbaArrayToArray(corbatext_tarray ca, text_tarray *ta)
|
---|
| 90 | {
|
---|
| 91 | unsigned int i;
|
---|
| 92 | corbaconv_text_t *cct;
|
---|
| 93 |
|
---|
| 94 | ta->clear();
|
---|
| 95 | ta->reserve(ca.length());
|
---|
| 96 | for (i = 0; i < ca.length(); i ++)
|
---|
| 97 | {
|
---|
| 98 | cct = new corbaconv_text_t(ca[i]);
|
---|
| 99 | ta->push_back(*cct); // cast to text_t
|
---|
| 100 | }
|
---|
| 101 | }
|
---|
| 102 |
|
---|
| 103 | void corbatext_arrayToCorbaArray(text_tarray ta, corbatext_tarray *_ca)
|
---|
| 104 | {
|
---|
| 105 | text_tarray::iterator here = ta.begin();
|
---|
| 106 | text_tarray::iterator end = ta.end();
|
---|
| 107 | corbatext_tarray ca(end - here);
|
---|
| 108 | unsigned int i;
|
---|
| 109 |
|
---|
| 110 | i = 0;
|
---|
| 111 | (*_ca).length(end - here);
|
---|
| 112 |
|
---|
| 113 | while (here != end)
|
---|
| 114 | {
|
---|
| 115 | corbatext_t_var ptr;
|
---|
| 116 | // cout << "Array: " << (*_ca).maximum() << " " << (*_ca).length() << endl;
|
---|
| 117 | ptr = corbatext_corbatext(*here);
|
---|
| 118 | (*_ca)[i] = ptr;
|
---|
| 119 | here ++;
|
---|
| 120 | i++;
|
---|
| 121 | }
|
---|
| 122 | }
|
---|
| 123 |
|
---|
| 124 | void corbatext_corbaArrayToSet(corbatext_tarray t, text_tset *ts)
|
---|
| 125 | { unsigned int i;
|
---|
| 126 |
|
---|
| 127 | for (i = 0; i < t.length(); i ++)
|
---|
| 128 | {
|
---|
| 129 | ts->insert((corbaconv_text_t) t[i]); // further typecast to text_t
|
---|
| 130 | }
|
---|
| 131 |
|
---|
| 132 | return;
|
---|
| 133 | }
|
---|
| 134 |
|
---|
| 135 | void corbatext_setToCorbaArray(text_tset ts, corbatext_tarray *t)
|
---|
| 136 | {
|
---|
| 137 | corbatext_t str;
|
---|
| 138 | text_tset::iterator here = ts.begin();
|
---|
| 139 | text_tset::iterator end = ts.end();
|
---|
| 140 | unsigned int i;
|
---|
| 141 |
|
---|
| 142 | i = 0;
|
---|
| 143 | while (here != end)
|
---|
| 144 | {
|
---|
| 145 | (*t).length(i+1);
|
---|
| 146 | (*t)[i] = *corbatext_corbatext(*here);
|
---|
| 147 | here ++;
|
---|
| 148 | i ++;
|
---|
| 149 | }
|
---|
| 150 | }
|
---|
| 151 |
|
---|
| 152 | void corbatext_mapToCorbaMap(text_tmap map, corbatext_tmap *cmap)
|
---|
| 153 | {
|
---|
| 154 | text_tmap::iterator here = map.begin();
|
---|
| 155 | text_tmap::iterator end = map.end();
|
---|
| 156 | unsigned int i = 0;
|
---|
| 157 |
|
---|
| 158 | while (here != end)
|
---|
| 159 | {
|
---|
| 160 | (*cmap).names.length(i+1);
|
---|
| 161 | (*cmap).values.length(i+1);
|
---|
| 162 | cmap->names[i] = *corbatext_corbatext((*here).first);
|
---|
| 163 | cmap->values[i] = *corbatext_corbatext((*here).second);
|
---|
| 164 | here ++;
|
---|
| 165 | i ++;
|
---|
| 166 | }
|
---|
| 167 | }
|
---|
| 168 |
|
---|
| 169 | void corbatext_corbaMapToMap(corbatext_tmap cmap, text_tmap &map)
|
---|
| 170 | {
|
---|
| 171 | unsigned int i;
|
---|
| 172 |
|
---|
| 173 | for (i = 0; i < cmap.names.length(); i ++)
|
---|
| 174 | {
|
---|
| 175 | map.insert(make_pair(*(new corbaconv_text_t(cmap.names[i])),
|
---|
| 176 | *(new corbaconv_text_t(cmap.values[i])))); // further typecast to text_t
|
---|
| 177 | }
|
---|
| 178 | }
|
---|
| 179 |
|
---|