/********************************************************************** * * corbaconv_text_t.mpp -- conversion support text_t <-> corba_text_t * Copyright (C) 1999 The New Zealand Digital Library Project * * A component of the Greenstone digital library software * from the New Zealand Digital Library Project at the * University of Waikato, New Zealand. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * * $Id$ * *********************************************************************/ // protocol header #include "corbaiface.h" using namespace gsdlInterface; #include "corbatext_t.h" #include "corbaconv_text_t.h" #if defined(GSDL_USE_OBJECTSPACE) # include #elif defined(GSDL_USE_STL_H) # if defined(GSDL_USE_ALGO_H) # include # else # include # endif #else # include #endif #ifdef HAVE_CONFIG_H # ifdef __WIN32__ # include "WIN32cfg.h" # else # include "mico/config.h" # endif #endif // #include "unitool.h" // **** //////////////////////////////////// // corbaconv_text_t methods //////////////////////////////////// corbaconv_text_t::corbaconv_text_t (corbatext_t t) { setCorbatext(t); } void corbaconv_text_t::getCorbatext(const text_t& t, corbatext_t &ct) { ct.encoding = 0; fillUsString(t,&ct.text); } void corbaconv_text_t::setCorbatext(text_t& t, corbatext_t ct) { t.setencoding(0); t.clear(); corbatext_usvector(ct, t.text_as_usvector()); } void corbaconv_text_t::fillUsString(const text_t& t, usString *us) { unsigned int i; usvector::const_iterator here = t.text_as_usvector().begin(); usvector::const_iterator end = t.text_as_usvector().end(); if (end == here) { return; } (*us).length(end - here); i = 0; while (here != end) { (*us)[i] = *here; i ++; here ++; } }