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