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