Changeset 1860 for trunk/gsdl/lib/text_t.cpp
- Timestamp:
- 2001-01-26T07:26:45+13:00 (23 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl/lib/text_t.cpp
r1310 r1860 22 22 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 23 23 * 24 * $Id$ 25 * 24 26 *********************************************************************/ 27 28 /* 29 $Log$ 30 Revision 1.20 2001/01/25 18:26:44 cs025 31 Included CORBA branch for first time 32 33 Revision 1.15.2.2 2000/04/05 10:19:38 syeates 34 added automatic conversion to allow text_t's to be <<'ed to ostreams 35 36 Revision 1.15.2.1 2000/04/04 15:02:29 cs025 37 Corba first commit 38 39 Revision 1.15 1999/10/14 22:52:39 sjboddie 40 joinchar can join using text_t string now too 41 42 Revision 1.14 1999/09/24 02:30:03 rjmcnab 43 added function has_unicode_letdig 44 45 Revision 1.13 1999/09/07 04:57:43 sjboddie 46 added gpl notice 47 48 Revision 1.12 1999/08/31 08:04:41 rjmcnab 49 Fixed a small but hard to find bug in getcarr 50 51 Revision 1.11 1999/07/01 04:05:09 rjmcnab 52 Optimised append functions slightly and added a reserve function. 53 54 Revision 1.10 1999/04/26 03:58:03 sjboddie 55 added is_number function 56 57 Revision 1.9 1999/04/06 22:17:24 rjmcnab 58 Added splits and joins using text_tset. 59 60 Revision 1.8 1999/02/28 23:14:41 rjmcnab 61 62 Added uc and lc to convert to uppercase and lowercase. 63 64 Revision 1.7 1999/02/21 22:26:39 rjmcnab 65 66 Made getint() a constant function. 67 68 Revision 1.6 1999/02/03 01:13:26 sjboddie 69 70 Got interface to handle subcollections and language subcollections - 71 committed changes made to some of the collections 72 73 Revision 1.5 1999/01/19 01:38:14 rjmcnab 74 75 Made the source more portable. 76 77 Revision 1.4 1999/01/12 01:51:00 rjmcnab 78 79 Standard header. 80 81 Revision 1.3 1999/01/08 02:33:16 rjmcnab 82 83 Added standard header to source files. 84 85 */ 25 86 26 87 #include "text_t.h" … … 38 99 #endif 39 100 101 #ifdef HAVE_CONFIG_H 102 # ifdef __WIN32__ 103 # include "WIN32cfg.h" 104 # else 105 # include "config.h" 106 # endif 107 #endif 108 40 109 41 110 #include "unitool.h" … … 44 113 // text_t methods 45 114 //////////////////////////////////// 115 116 // new stream converter ... 117 ostream& operator<< (ostream &o, const text_t text) 118 { 119 text_t::const_iterator ithere = text.begin(); 120 text_t::const_iterator itend = text.end(); 121 122 while (ithere != itend) 123 { 124 if (*ithere < 256) 125 { 126 o << (unsigned char)(*ithere); 127 } 128 else 129 { 130 // put a space or a question mark depending on what 131 // the character is. Question marks tell the user that 132 // they are missing some information. 133 if (is_unicode_space (*ithere)) 134 o << ' '; 135 else 136 o << '?'; 137 } 138 ithere++; 139 } 140 141 return o; 142 } 46 143 47 144 text_t::text_t () … … 64 161 appendcstr (s); 65 162 } 163 66 164 67 165 void text_t::append (const text_t &t) … … 265 363 } 266 364 return first; 365 } 366 367 text_t::iterator findword (text_t::iterator first, text_t::iterator last, 368 const text_t& word) 369 { 370 text_t::const_iterator word_begin = word.begin(); 371 text_t::const_iterator word_end = word.end(); 372 373 while (first != last) 374 { 375 text_t::iterator char_match = first; 376 text_t::const_iterator word_here = word_begin; 377 while (word_here!=word_end) 378 { 379 if (*char_match != *word_here) 380 { 381 break; 382 } 383 char_match++; 384 word_here++; 385 } 386 if (word_here==word_end) 387 { 388 return first; 389 } 390 first++; 391 } 392 return last; // get to here only if there is no match 267 393 } 268 394
Note:
See TracChangeset
for help on using the changeset viewer.