Changeset 1073


Ignore:
Timestamp:
2000-04-05T22:19:39+12:00 (24 years ago)
Author:
syeates
Message:

added automatic conversion to allow text_t's to be <<'ed to ostreams

Location:
branches/corba/gsdl/lib
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/corba/gsdl/lib/text_t.cpp

    r1067 r1073  
    2828/*
    2929   $Log$
     30   Revision 1.15.2.2  2000/04/05 10:19:38  syeates
     31   added automatic conversion to allow text_t's to be <<'ed to ostreams
     32
    3033   Revision 1.15.2.1  2000/04/04 15:02:29  cs025
    3134   Corba first commit
     
    107110// text_t methods
    108111////////////////////////////////////
     112
     113// new stream converter ...
     114ostream& operator<< (ostream &o, const text_t text)
     115{
     116  text_t::const_iterator ithere = text.begin();
     117  text_t::const_iterator itend = text.end();
     118
     119  while (ithere != itend)
     120    {
     121      if (*ithere < 256)
     122    {
     123      o << (unsigned char)(*ithere);
     124    }
     125      else
     126    {
     127    // put a space or a question mark depending on what
     128    // the character is. Question marks tell the user that
     129    // they are missing some information.
     130    if (is_unicode_space (*ithere))
     131      o << ' ';
     132    else
     133      o << '?';
     134      }
     135      ithere++;
     136    }
     137
     138  return o;
     139}
    109140
    110141text_t::text_t ()
  • branches/corba/gsdl/lib/text_t.h

    r1067 r1073  
    167167  char *getcarr(size_type &len) const;
    168168  char *getcstr() const;
    169 };
    170 
     169
     170};
     171
     172// new stream converter ...
     173ostream& operator<< (ostream &o, const text_t text);
    171174
    172175inline text_t operator+(const text_t &t1, const text_t &t2)
Note: See TracChangeset for help on using the changeset viewer.