// standard headers #include #include // protocol headers #include "corbaiface.h" using namespace gsdlInterface; // greenstone headers #include "corbaconv_text_t.h" //local headers #include "corbatext_t.h" void corbatext_fillChar(corbatext_t *t, char *text) { unsigned int i; t->text.length(0); if (text == NULL) { return; } for (i = 0; i < strlen(text); i ++) { t->text[i] = text[i]; } t->encoding = 0; } void corbatext_usvector(corbatext_t t, usvector& us) { unsigned int i; for (i = 0; i < t.text.length(); i ++) { us.push_back(t.text[i]); } } char *corbatext_string(corbatext_t t) { char *lcopy; unsigned int i; lcopy = (char *) malloc(t.text.length() + 1); for (i = 0; i < t.text.length(); i ++) { lcopy[i] = (char) t.text[i]; } lcopy[i] = '\0'; return lcopy; } corbatext_t_var corbatext_corbatext(text_t t) { corbatext_t_var ct; // usString_var us; // cout << "Making text\n"; ct = new corbatext_t; // ct->text.length(20); // us = new usString(20); // cout << ct->text.length() << endl; // cout << ct->text.maximum() << endl; corbaconv_text_t::fillUsString(t,&ct->text); //t.fillUsString(us); // delete us; // cout << "Encoding text\n"; ct->encoding = 0; // cout << "Encoding text\n"; return ct; } int corbatext_corbatext(text_t t, corbatext_t_var ct) { cout << "A" << endl; corbaconv_text_t::fillUsString(t,&ct->text); cout << "B" << endl; ct->encoding = 0; cout << "C" << endl; } void corbatext_corbaArrayToArray(corbatext_tarray ca, text_tarray *ta) { unsigned int i; corbaconv_text_t *cct; ta->clear(); ta->reserve(ca.length()); for (i = 0; i < ca.length(); i ++) { cct = new corbaconv_text_t(ca[i]); ta->push_back(*cct); // cast to text_t } } void corbatext_arrayToCorbaArray(text_tarray ta, corbatext_tarray *_ca) { text_tarray::iterator here = ta.begin(); text_tarray::iterator end = ta.end(); corbatext_tarray ca(end - here); unsigned int i; i = 0; (*_ca).length(end - here); while (here != end) { corbatext_t_var ptr; // cout << "Array: " << (*_ca).maximum() << " " << (*_ca).length() << endl; ptr = corbatext_corbatext(*here); (*_ca)[i] = ptr; here ++; i++; } } void corbatext_corbaArrayToSet(corbatext_tarray t, text_tset *ts) { unsigned int i; for (i = 0; i < t.length(); i ++) { ts->insert((corbaconv_text_t) t[i]); // further typecast to text_t } return; } void corbatext_setToCorbaArray(text_tset ts, corbatext_tarray *t) { corbatext_t str; text_tset::iterator here = ts.begin(); text_tset::iterator end = ts.end(); unsigned int i; i = 0; while (here != end) { (*t).length(i+1); (*t)[i] = *corbatext_corbatext(*here); here ++; i ++; } } void corbatext_mapToCorbaMap(text_tmap map, corbatext_tmap *cmap) { text_tmap::iterator here = map.begin(); text_tmap::iterator end = map.end(); unsigned int i = 0; while (here != end) { (*cmap).names.length(i+1); (*cmap).values.length(i+1); cmap->names[i] = *corbatext_corbatext((*here).first); cmap->values[i] = *corbatext_corbatext((*here).second); here ++; i ++; } } void corbatext_corbaMapToMap(corbatext_tmap cmap, text_tmap &map) { unsigned int i; for (i = 0; i < cmap.names.length(); i ++) { map.insert(make_pair(*(new corbaconv_text_t(cmap.names[i])), *(new corbaconv_text_t(cmap.values[i])))); // further typecast to text_t } }