[1860] | 1 | /**********************************************************************
|
---|
| 2 | *
|
---|
| 3 | * corbaconv_text_t.mpp -- conversion support text_t <-> corba_text_t
|
---|
| 4 | * Copyright (C) 1999 The New Zealand Digital Library Project
|
---|
| 5 | *
|
---|
| 6 | * A component of the Greenstone digital library software
|
---|
| 7 | * from the New Zealand Digital Library Project at the
|
---|
| 8 | * University of Waikato, New Zealand.
|
---|
| 9 | *
|
---|
| 10 | * This program is free software; you can redistribute it and/or modify
|
---|
| 11 | * it under the terms of the GNU General Public License as published by
|
---|
| 12 | * the Free Software Foundation; either version 2 of the License, or
|
---|
| 13 | * (at your option) any later version.
|
---|
| 14 | *
|
---|
| 15 | * This program is distributed in the hope that it will be useful,
|
---|
| 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 18 | * GNU General Public License for more details.
|
---|
| 19 | *
|
---|
| 20 | * You should have received a copy of the GNU General Public License
|
---|
| 21 | * along with this program; if not, write to the Free Software
|
---|
| 22 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
---|
| 23 | *
|
---|
| 24 | * $Id: corbaconv_text_t.mpp 2113 2001-03-05 00:54:26Z say1 $
|
---|
| 25 | *
|
---|
| 26 | *********************************************************************/
|
---|
| 27 |
|
---|
| 28 |
|
---|
| 29 | // protocol header
|
---|
| 30 | #include "corbaiface.h"
|
---|
| 31 | using namespace gsdlInterface;
|
---|
| 32 |
|
---|
| 33 | #include "corbatext_t.h"
|
---|
| 34 |
|
---|
| 35 | #include "corbaconv_text_t.h"
|
---|
| 36 |
|
---|
| 37 |
|
---|
| 38 | #if defined(GSDL_USE_OBJECTSPACE)
|
---|
| 39 | # include <ospace\std\algorithm>
|
---|
| 40 | #elif defined(GSDL_USE_STL_H)
|
---|
| 41 | # if defined(GSDL_USE_ALGO_H)
|
---|
| 42 | # include <algo.h>
|
---|
| 43 | # else
|
---|
| 44 | # include <algorithm.h>
|
---|
| 45 | # endif
|
---|
| 46 | #else
|
---|
| 47 | # include <algorithm>
|
---|
| 48 | #endif
|
---|
| 49 |
|
---|
| 50 | #ifdef HAVE_CONFIG_H
|
---|
| 51 | # ifdef __WIN32__
|
---|
| 52 | # include "WIN32cfg.h"
|
---|
| 53 | # else
|
---|
[2113] | 54 | # include "mico/config.h"
|
---|
[1860] | 55 | # endif
|
---|
| 56 | #endif
|
---|
| 57 |
|
---|
| 58 |
|
---|
| 59 | // #include "unitool.h" // ****
|
---|
| 60 |
|
---|
| 61 | ////////////////////////////////////
|
---|
| 62 | // corbaconv_text_t methods
|
---|
| 63 | ////////////////////////////////////
|
---|
| 64 |
|
---|
| 65 | corbaconv_text_t::corbaconv_text_t (corbatext_t t)
|
---|
| 66 | {
|
---|
| 67 | setCorbatext(t);
|
---|
| 68 | }
|
---|
| 69 |
|
---|
| 70 | void corbaconv_text_t::getCorbatext(const text_t& t, corbatext_t &ct)
|
---|
| 71 | {
|
---|
| 72 | ct.encoding = 0;
|
---|
| 73 | fillUsString(t,&ct.text);
|
---|
| 74 | }
|
---|
| 75 |
|
---|
| 76 | void corbaconv_text_t::setCorbatext(text_t& t, corbatext_t ct)
|
---|
| 77 | {
|
---|
| 78 | t.setencoding(0);
|
---|
| 79 | t.clear();
|
---|
| 80 | corbatext_usvector(ct, t.text_as_usvector());
|
---|
| 81 | }
|
---|
| 82 |
|
---|
| 83 | void corbaconv_text_t::fillUsString(const text_t& t, usString *us)
|
---|
| 84 | {
|
---|
| 85 | unsigned int i;
|
---|
| 86 | usvector::const_iterator here = t.text_as_usvector().begin();
|
---|
| 87 | usvector::const_iterator end = t.text_as_usvector().end();
|
---|
| 88 |
|
---|
| 89 |
|
---|
| 90 | if (end == here)
|
---|
| 91 | {
|
---|
| 92 | return;
|
---|
| 93 | }
|
---|
| 94 | (*us).length(end - here);
|
---|
| 95 | i = 0;
|
---|
| 96 |
|
---|
| 97 | while (here != end)
|
---|
| 98 | {
|
---|
| 99 | (*us)[i] = *here;
|
---|
| 100 | i ++;
|
---|
| 101 | here ++;
|
---|
| 102 | }
|
---|
| 103 |
|
---|
| 104 | }
|
---|