Fresco/Babylon/src Boundaries.cc,NONE,1.1 exceptions.cc,NONE,1.1 Char.cc,1.8,1.9 Dictionary.cc,1.15,1.16 Makefile.in,1.27,1.28 String.cc,1.12,1.13 traits.cc,1.1,1.2 vis_iterator.cc,1.3,NONE

Tobias Hunger <[email protected]> Fri, 01 Aug 2003 11:47:49 -0500
Newsgroups gmane.comp.video.fresco.cvs
Message-ID <[email protected]>
Update of /cvs/fresco/Fresco/Babylon/src
In directory purcel:/tmp/cvs-serv24256/Babylon/src

Modified Files:
	Char.cc Dictionary.cc Makefile.in String.cc traits.cc 
Added Files:
	Boundaries.cc exceptions.cc 
Removed Files:
	vis_iterator.cc 
Log Message:
Babylon work over:
 * Use iconv to convert characters to/from Babylon
 * Updtae to Unicode Version 4.0
 * Added unit tests (some fail for now, still need to work on that)

 * Removed the VisualTextBuffer from the CommandKit: I still like the idea,
   unfortunately it won't work out in the real world:-|

 * Updated code to the changed Babylon interfaces whereever needed.


--- NEW FILE: Boundaries.cc ---
/*$Id: Boundaries.cc,v 1.1 2003/08/01 16:47:15 tobias Exp $
 *
 * This source file is a part of the Berlin Project.
 * Copyright (C) 1999-2003 Tobias Hunger <[email protected]>
 * http://www.fresco.org
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library 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
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this library; if not, write to the
 * Free Software Foundation, Inc., 675 Mass Ave, Cambridge,
 * MA 02139, USA.
 */

#include <Babylon/internal/Boundaries.hh>
#include <Babylon/Char.hh>

bool
Babylon::is_graphem_cluster_boundary(const Babylon::Char & f,
				     const Babylon::Char & s)
{
    // Break after Start_Of_Text and before End_Of_Text
    if (UC_START_OF_TEXT == f.value() ||
	UC_END_OF_TEXT == s.value()) return 1;
    // Don't break between CR and LF
    if (UC_CARRIAGE_RETURN == f.value() &&
	UC_LINE_FEED == s.value()) return 0;
    // Break before/after (Control | CR | LF)
    if (f.is_Control() ||
	s.is_Control()) return 1;
    // Do not break Hangul syllable sequences.
    if ((f.is_hangul_L() && (s.is_hangul_L() || s.is_hangul_V() ||
			     s.is_hangul_LV() || s.is_hangul_LVT())) ||
	((f.is_hangul_LV() || f.is_hangul_V()) && (s.is_hangul_V() ||
						   s.is_hangul_T())) ||
	((f.is_hangul_LVT() || f.is_hangul_T()) && s.is_hangul_T()))
	return 0;
    // Don't break before extending characters.
    if (s.is_Grapheme_Extend()) return 0;
    // Otherwise break everywhere.
    return 1;
}

bool Babylon::is_word_boundary(const Babylon::Char & f,
		      const Babylon::Char & s)
{
    if (UC_START_OF_TEXT == f.value() ||
	UC_END_OF_TEXT == s.value()) return 1;
    return 0;
}

bool Babylon::is_sentense_boundary(const Babylon::Char & f,
				   const Babylon::Char & s)
{
    if (UC_START_OF_TEXT == f.value() ||
	UC_END_OF_TEXT == s.value()) return 1;
    return 0;
}

--- NEW FILE: exceptions.cc ---
/*$Id: exceptions.cc,v 1.1 2003/08/01 16:47:15 tobias Exp $
 *
 * This source file is a part of the Fresco Project.
 * Copyright (C) 1999-2003 Tobias Hunger <[email protected]>
 * http://www.fresco.org
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library 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
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this library; if not, write to the
 * Free Software Foundation, Inc., 675 Mass Ave, Cambridge,
 * MA 02139, USA.
 */

#include <Babylon/exceptions.hh>

#include <iomanip>
#include <sstream>

const char * Babylon::Undefined_Property::what() const throw()
{
    std::ostringstream res;
    res << std::setw(4) << std::setfill('0') << std::hex; 
    switch (my_error_prop)
    {
    case PROP_CHARACTER:
	res << "(" <<  my_error_uc << " Character is undefined";
	break;
    case PROP_UNICODE_VALUE:
	res << "(" << my_error_uc
	    << ") Character has no unicode value.. how did this happen?";
	break;
    case PROP_GEN_CAT:
	res << "(" << my_error_uc
	    << ") Character has no general category... how did this happen?";
	break;
    case PROP_CHAR_DECOMP:
	res << "(" << my_error_uc << ") Character has no decomposition";
	break;
    case PROP_COMB_CLASS :
	res << "(" << my_error_uc
	    << ") Character has no canonical combining class.";
	break;
    case PROP_BIDIR_PROPS:
	res << "(" << my_error_uc << ") Character has no bidir property.";
	break;
    case PROP_DEC_DIGIT_VALUE:
	res << "(" << my_error_uc << ") Character has no decimal digit value.";
	break;
    case PROP_DIGIT_VALUE:
	res << "(" << my_error_uc << ") Character has no digit value.";
	break;
    case PROP_NUMERIC_VALUE:
	res << "(" << my_error_uc << ") Character has no numeric value.";
	break;
    case PROP_IS_MIRRORED:
	res << "(" << my_error_uc 
	    << ") Mirroring property missing... how did this happen?";
	break;
    case PROP_UPPER_EQUIV:
	res << "(" << my_error_uc
	    << ") Uppercase equivalent missing... how did this happen?";
	break;
    case PROP_LOWER_EQUIV:
	res << "(" << my_error_uc
	    << ") Lowercase equivalent missing... how did this happen?";
	break;
    case PROP_TITLE_EQUIV:
	res << "(" << my_error_uc
	    << ") Titlecase equivalent missing... how did this happen?";
	break;
    case PROP_SCRIPT:
	res << "(" << my_error_uc
	    << ") Character belongs to no script... how did this happen?";
	break;
    case PROP_EA_WIDTH:
	res << "(" << my_error_uc
	    << ") EA width property missing... how did this happen?";
	break;
    case PROP_LINE_BREAKING:
	res << "(" << my_error_uc
	    << ") linebreak property missing... how did this happen?";
	break;
    case PROP_MAX:
	res << "(" << my_error_uc
	    << ") PROP_MAX throw... how did this happen?";
	break;	
    }
    return res.str().c_str();
}


const char * Babylon::Transfer_Error::what() const throw()
{
    switch (my_error)
    {
    case TRANS_ICONV_FAILED:
	return("iconv failed to transform some characters.");
    case TRANS_CAN_NOT_ENCODE:
	return("Can not encode from Babylon to foreign format.");
    default:
	return("Can not decode from foreign format to Babylon.");
    }
}


const char * Babylon::Block_Error::what() const throw()
{
    std::ostringstream res;
    res << std::hex << std::setw(4) << std::setfill('0');
    res << "(" << my_block_start << "-" << my_block_end << "): "
	<< my_error_message;
    return res.str().c_str();
}

Index: Char.cc
===================================================================
RCS file: /cvs/fresco/Fresco/Babylon/src/Char.cc,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- Char.cc	18 Nov 2002 16:19:27 -0000	1.8
+++ Char.cc	1 Aug 2003 16:47:15 -0000	1.9
@@ -1,9 +1,9 @@
 /*
  *$Id$
  *
- * This source file is a part of the Berlin Project.
- * Copyright (C) 1999,2000 Tobias Hunger <[email protected]>
- * http://www.berlin-consortium.org
+ * This source file is a part of the Fresco Project.
+ * Copyright (C) 1999-2003 Tobias Hunger <[email protected]>
+ * http://www.fresco.org
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -21,228 +21,646 @@
  * MA 02139, USA.
  */
 
-#include <Babylon/String.hh>
 #include <Babylon/Char.hh>
-#include <Prague/Sys/Tracer.hh>
-
-// Conversion:
-Babylon::UTF8_string Babylon::Char::utf8() const throw (Trans_Error) {
-    Prague::Trace trace("Babylon::Char::utf8()");
-    unsigned int chars_needed;
-    
-    UCS4 c = m_value;
-    UTF8_string res;
+#include <Babylon/String.hh>
+#include <Babylon/internal/Dictionary.hh>
+#include <Babylon/internal/utfstrings.hh>
 
-    if      (c <= 0x0000007F) chars_needed = 0;
-    else if (c <= 0x000007FF) chars_needed = 1;
-    else if (c <= 0x0000FFFF) chars_needed = 2;
-    else if (c <= 0x001FFFFF) chars_needed = 3;
-    else if (c <= 0x03FFFFFF) chars_needed = 4;
-    else if (c <= 0x7FFFFFFF) chars_needed = 5;
-    else throw Trans_Error(TRANS_CAN_NOT_ENCODE);
+#include <Prague/Sys/Tracer.hh>
 
-    for (unsigned int i = chars_needed; i > 0; --i) {
-        UCS1 t = 0x80;
-        t |= UCS1(c & 0x3f);
-        c = c >> 6;
-        res = t + res;
-    }
+#include <memory>
 
-    if ( !chars_needed ) {
-      res = UCS1(c & 0x7F);
-    }
-    else {
-        UCS1 t = 0xFE << (6 - chars_needed);
-        t |= UCS1(c & 0xFF);
-        res = t + res;
-    }
-    return res;
+extern "C"
+{
+#include <iconv.h>
 }
 
-Babylon::UTF16_string Babylon::Char::utf16() const throw (Trans_Error) {
-    Prague::Trace trace("Babylon::Char::utf16()");
-    UTF16_string res;
-    UCS4 c = m_value;
-    if (c > 0x0010FFFF)
-	throw Trans_Error(TRANS_CAN_NOT_ENCODE);
-    if (c < 0x00010000)
-	res += UCS2(c);
-    else {
-	c -= 0x00010000;
-	UCS2 h = 0xD800;
-	UCS2 l = 0xDC00;
-	res += (h | (c >> 10));
-	res += (l | (c & 0x3FF));
-    }
+// Conversion:
 
-    return res;
-}
+std::string Babylon::Char::convert(const std::string format) const
+    throw (Transfer_Error)
+{
+    Prague::Trace trace("Babylon::Char::convert(OUT OF Babylon)");
 
-Babylon::UTF32_string Babylon::Char::utf32() const throw (Trans_Error) {
-    Prague::Trace trace("Babylon::Char::utf32()");
-    if (m_value > 0x10FFFF)
-        throw Trans_Error(TRANS_CAN_NOT_ENCODE);
-    UTF32_string res;//(m_value, Babylon::NORM_NONE);
-    return res += m_value;
-}
+    // prepare input buffer
+    size_t in_bound(sizeof(UCS4));
 
-Babylon::UTF8_string::const_iterator
-Babylon::Char::utf8(const Babylon::UTF8_string & s,
-		    Babylon::UTF8_string::const_iterator it)
-    throw (Trans_Error) {
-    Prague::Trace trace("Babylon::Char::utf8(...)");
- 
-    // rfc2279.txt: The trasfromation of UCS2 to UCS1 should be:
-    // UCS2 ---> UCS4 ---> UCS1, so surrogates of UCS2 are removed
+    // prepare output buffer
+    // 16Byte should be more then enough to encode two characters;-)
+    std::auto_ptr<char> out_buf(new char[16]);
+    size_t out_bound(16);
 
-    UCS4 c = 0;
-    unsigned int chars_needed;
+    iconv_wrapper(Babylon::internal_format,
+		  reinterpret_cast<const char *>(&my_value), in_bound,
+		  format, out_buf.get(), out_bound);
     
-    if      ((*it & 0x80) == 0) chars_needed = 0; // *s_it == 0xxx xxxx
-    else if ((*it & 0x40) == 0)                   // *s_it == 10xx xxxx, should only
-	                                           // happen after a character
-	                                           // starting with 11xx xxxx
-	throw Trans_Error(TRANS_CAN_NOT_DECODE);
-    else if ((*it & 0x20) == 0) chars_needed = 1; // *s_it == 110x xxxx
-    else if ((*it & 0x10) == 0) chars_needed = 2; // *s_it == 1110 xxxx
-    else if ((*it & 0x08) == 0) chars_needed = 3; // *s_it == 1111 0xxx
-    else if ((*it & 0x04) == 0) chars_needed = 4; // *s_it == 1111 10xx
-    else if ((*it & 0x02) == 0) chars_needed = 5; // *s_it == 1111 110x
-    else throw Trans_Error(TRANS_CAN_NOT_DECODE); // *s_it == 1111 111x,
-                                               // should not happen in
-                                               // a sequence of UTF8-Characters
+    // put result into a string
+    std::string result(out_buf.get(), 16 - out_bound);
+    
+    return result;
+}
 
-    if ( !chars_needed ) {
-        c = UCS4(*it);
+size_t Babylon::Char::convert(const std::string & s,
+			      const size_t pos,
+			      const std::string format)
+    throw (Transfer_Error)
+{
+    Prague::Trace trace("Babylon::Char::convert(INTO babylon)");
+    
+    // check wether start position is valid.
+    if (pos >= s.length())
+    {
+	my_value = Babylon::UC_NULL;
+	return(std::string::npos);
     }
-    else {
-        c = (*it) & (0x3F >> chars_needed);
 
-        for (int i = 1; i <= chars_needed; ++i) {
-	    if ( (++it == s.end()) || ((*it & 0xc0) != 0x80) )
-		// either we are at the end of the UTF8-sequence or the current
-		// character is not 10xx xxxx.
-		throw Trans_Error(TRANS_CAN_NOT_DECODE);
-            c = c << 6;
-            c |= UCS4(*it & 0x3F);
-	}
+    // prepare input buffer
+    size_t in_bound(s.length() - pos);
+    
+    // prepare output buffer
+    UCS4 c;
+    size_t out_bound(sizeof(UCS4));
 
-        // Now we check the range of the value decodifed, to avoid problems
-        // of seccurity (Ex: C0 80 is the NULL char).
-        switch (chars_needed) {
-           case 1:
-               if (c < 0x80) throw Trans_Error(TRANS_CAN_NOT_DECODE);
-               break;
-           case 2:
-               if (c < 0x800) throw Trans_Error(TRANS_CAN_NOT_DECODE);
-               break;
-           case 3:
-               if (c < 0x10000) throw Trans_Error(TRANS_CAN_NOT_DECODE);
-               break;
-           case 4:
-               if (c < 0x200000) throw Trans_Error(TRANS_CAN_NOT_DECODE);
-               break;
-           case 5:
-               if (c < 0x4000000) throw Trans_Error(TRANS_CAN_NOT_DECODE);
-               break;
-           default:
-               throw Trans_Error(TRANS_CAN_NOT_DECODE);
-        }
-    }
-    m_value = UCS4(c);
-    return ++it;
-}
+    iconv_wrapper(format, s.data() + pos, in_bound,
+		  Babylon::internal_format,
+		  reinterpret_cast<char *>(&c), out_bound);
 
-Babylon::UTF16_string::const_iterator
-Babylon::Char::utf16(const Babylon::UTF16_string & s,
-		     Babylon::UTF16_string::const_iterator it)
-    throw (Trans_Error) {
-    Prague::Trace trace("Babylon::Char::utf16(...)");
-    UCS4 c = *it;
-    if (c >= 0xD800 && c <= 0xDFFF) {
-	// we found part of a surrogate pair...
-	if (c >= 0xDC00)
-	    // it was a low surrogate...
-	    throw Trans_Error(TRANS_CAN_NOT_DECODE);
-	++it;
-	if (it == s.end() || *it < 0xDC00 || *it > 0xDFFF)
-	    // didn't find a corresponding low surrogate...
-	    throw Trans_Error(TRANS_CAN_NOT_DECODE);
-	c = (((c & 0x3FF) << 10) | (*it & 0x3FF)) + 0x10000;
-    }
-    m_value = c;
-    return ++it;
+    my_value = c;
+    return (0 == in_bound) ? std::string::npos : s.length() - in_bound;
 }
 
-Babylon::UTF32_string::const_iterator
-Babylon::Char::utf32(const Babylon::UTF32_string & s,
-		     Babylon::UTF32_string::const_iterator it)
-    throw (Trans_Error) {
-    Prague::Trace trace("Babylon::Char::utf32(...)");
-    if (*it > 0x10FFFF)
-        throw Trans_Error(TRANS_CAN_NOT_ENCODE);
-    m_value = *it;
-    return ++it;
-}
+void Babylon::Char::iconv_wrapper(const std::string & in_format,
+				  const char * in_buf,
+				  size_t & in_buf_size,
+				  const std::string & out_format,
+				  char * out_buf,
+				  size_t & out_buf_size) const
+{
+    // Setup iconv
+    iconv_t cd = iconv_open(out_format.c_str(), in_format.c_str());
 
-bool Babylon::Char::is_Alphabetic() const throw (Block_Error) {
-    Prague::Trace trace("Babylon::Char::is_Alphabetic()");
-    Gen_Cat cat = Dictionary::instance()->category(m_value);
-    return (cat == CAT_Ll ||
-	    cat == CAT_Lu ||
-	    cat == CAT_Lt ||
-	    cat == CAT_Lm ||
-	    cat == CAT_Lo ||
-	    Dictionary::instance()->is_Other_Alphabetic(m_value));
-}
+    if (iconv_t(-1) == cd)
+	throw Trans_Error(Babylon::TRANS_ICONV_FAILED);
 
-bool Babylon::Char::is_ID_Start() const throw (Block_Error) {
-    Prague::Trace trace("Babylon::Char::is_ID_Start()");
-    Gen_Cat cat = Dictionary::instance()->category(m_value);
-    return (cat == CAT_Ll ||
-	    cat == CAT_Lu ||
-	    cat == CAT_Lt ||
-	    cat == CAT_Lm ||
-	    cat == CAT_Lo ||
-	    cat == CAT_Nl);
-}
+    // convert
+    size_t retval = iconv(cd,
+			  const_cast<char **>(&in_buf), &in_buf_size,
+			  &out_buf, &out_buf_size);
 
-bool Babylon::Char::is_ID_Continue() const throw (Block_Error) {
-    Prague::Trace trace("Babylon::Char::is_ID_Continue()");
-    Gen_Cat cat = Dictionary::instance()->category(m_value);
-    return (cat == CAT_Ll ||
-	    cat == CAT_Lu ||
-	    cat == CAT_Lt ||
-	    cat == CAT_Lm ||
-	    cat == CAT_Lo ||
-	    cat == CAT_Nl ||
-	    cat == CAT_Mn ||
-	    cat == CAT_Mc ||
-	    cat == CAT_Nd ||
-	    cat == CAT_Pc);
+    if (-1 == retval)
+    {
+        if (E2BIG != errno) throw Trans_Error(Babylon::TRANS_ICONV_FAILED);
+    }
+
+    // clean up iconv
+    iconv_close(cd);
 }
 
 // TRANSFORMATIONS:
 void Babylon::Char::to_lower()
-    throw (Block_Error) {
+    throw (Block_Error)
+{
     Prague::Trace trace("Babylon::Char::to_lower()");
     *this = this->lowercase();
 } // to_lowercase
 
 void Babylon::Char::to_upper()
-    throw (Block_Error) {
+    throw (Block_Error)
+{
     Prague::Trace trace("Babylon::Char::to_upper()");
+    
     *this = this->uppercase();
 } // to_uppercase
 
 void Babylon::Char::to_title()
-    throw (Block_Error) {
+    throw (Block_Error)
+{
     Prague::Trace trace("Babylon::Char::to_title()");
+
     *this = this->titlecase();
 } // to_titlecase
 
 Babylon::String Babylon::Char::decompose() const
-    throw (Undefined_Property, Block_Error) {
-    Prague::Trace trace("Babylon::Char::decompose()");
-    return String(Dictionary::instance()->decompose(m_value));
+    throw (Undefined_Property, Block_Error)
+{
+    String r;
+    get_from_UTF32(Dictionary::instance()->decompose(my_value), r);
+    return r;
 } // decompose
+
+bool Babylon::Char::exclude_from_composition() const
+    throw (Block_Error)
+{
+    return Dictionary::instance()->exclude_from_composition(my_value);
+}
+
+Babylon::Char Babylon::Char::uppercase() const throw (Block_Error)
+{
+  return Dictionary::instance()->uppercase(my_value);
+}
+
+Babylon::Char Babylon::Char::lowercase() const throw (Block_Error)
+{
+    return Dictionary::instance()->lowercase(my_value);
+}
+
+Babylon::Char Babylon::Char::titlecase() const throw (Block_Error)
+{
+    return Dictionary::instance()->titlecase(my_value);
+}
+
+float Babylon::Char::numeric_value() const
+    throw (Undefined_Property, Block_Error)
+{
+    return Dictionary::instance()->numeric_value(my_value);
+}
+
+int Babylon::Char::digit_value() const
+    throw (Undefined_Property, Block_Error)
+{
+    return Dictionary::instance()->digit_value(my_value);
+}
+
+int Babylon::Char::dec_digit_value() const
+    throw (Undefined_Property, Block_Error)
+{
+    return Dictionary::instance()->dec_digit_value(my_value);
+}
+
+bool Babylon::Char::is_Digit() const throw (Block_Error)
+{
+    return Dictionary::instance()->is_Digit(my_value);
+}
+
+bool Babylon::Char::is_Numeric() const throw (Block_Error)
+{
+    return Dictionary::instance()->is_Numeric(my_value);
+}
+
+bool Babylon::Char::is_Decimal_Digit() const throw (Block_Error)
+{
+    return Dictionary::instance()->is_Decimal_Digit(my_value);
+}
+
+std::string Babylon::Char::blockname() const throw (Block_Error)
+{
+    return Dictionary::instance()->blockname(my_value);
+}
+
+Babylon::Gen_Cat Babylon::Char::category() const
+    throw (Undefined_Property, Block_Error)
+{
+    return Dictionary::instance()->category(my_value);
+}
+
+Babylon::Bidir_Props Babylon::Char::direction() const
+    throw (Undefined_Property, Block_Error)
+{
+    return Dictionary::instance()->bidir_props(my_value);
+}
+
+Babylon::Can_Comb_Class Babylon::Char::comb_class() const
+    throw (Undefined_Property, Block_Error)
+{
+    return Dictionary::instance()->comb_class(my_value);
+}
+
+Babylon::Char_Decomp Babylon::Char::decomp_type() const
+    throw (Undefined_Property, Block_Error)
+{
+    return Dictionary::instance()->decomp_type(my_value);
+}
+
+bool Babylon::Char::must_mirror() const
+    throw (Undefined_Property, Block_Error)
+{
+    return Dictionary::instance()->must_mirror(my_value);
+}
+
+Babylon::EA_Width  Babylon::Char::EA_width() const
+    throw (Undefined_Property, Block_Error)
+{
+    return Dictionary::instance()->EA_width(my_value);
+}
+
+Babylon::Line_Break Babylon::Char::linebreak() const
+    throw (Undefined_Property, Block_Error)
+{
+    return Dictionary::instance()->linebreak(my_value);
+}
+
+bool Babylon::Char::is_defined() const 
+    throw (Block_Error)
+{
+    return Dictionary::instance()->is_defined(my_value);
+}
+
+// Properties
+bool Babylon::Char::is_White_Space() const throw (Block_Error)
+{
+    return Dictionary::instance()->is_White_Space(my_value);
+}
+
+bool Babylon::Char::is_Bidi_Control() const throw (Block_Error)
+{
+    return Dictionary::instance()->is_Bidi_Control(my_value);
+}
+
+bool Babylon::Char::is_Join_Control() const throw (Block_Error)
+{
+    return Dictionary::instance()->is_Join_Control(my_value);
+}
+
+bool Babylon::Char::is_Dash() const throw (Block_Error)
+{
+    return Dictionary::instance()->is_Dash(my_value);
+}
+
+bool Babylon::Char::is_Hyphen() const throw (Block_Error)
+{
+    return Dictionary::instance()->is_Hyphen(my_value);
+}
+
+bool Babylon::Char::is_Quotation_Mark() const throw (Block_Error)
+{
+    return Dictionary::instance()->is_Quotation_Mark(my_value);
+}
+
+bool Babylon::Char::is_Terminal_Punctuation() const throw (Block_Error)
+{
+    return Dictionary::instance()->is_Terminal_Punctuation(my_value);
+}
+
+bool Babylon::Char::is_Other_Math() const throw (Block_Error)
+{
+    return Dictionary::instance()->is_Other_Math(my_value);
+}
+
+bool Babylon::Char::is_Hex_Digit() const throw (Block_Error)
+{
+    return Dictionary::instance()->is_Hex_Digit(my_value);
+}
+
+bool Babylon::Char::is_ASCII_Hex_Digit() const throw (Block_Error)
+{
+    return Dictionary::instance()->is_ASCII_Hex_Digit(my_value);
+}
+
+bool Babylon::Char::is_Other_Alphabetic() const throw (Block_Error)
+{
+    return Dictionary::instance()->is_Other_Alphabetic(my_value);
+}
+
+bool Babylon::Char::is_Ideographic() const throw (Block_Error)
+{
+    return Dictionary::instance()->is_Ideographic(my_value);
+}
+
+bool Babylon::Char::is_Diacritic() const throw (Block_Error)
+{
+    return Dictionary::instance()->is_Diacritic(my_value);
+}
+
+bool Babylon::Char::is_Extender() const throw (Block_Error)
+{
+    return Dictionary::instance()->is_Extender(my_value);
+}
+
+bool Babylon::Char::is_Other_Lowercase() const throw (Block_Error)
+{
+    return Dictionary::instance()->is_Other_Lowercase(my_value);
+}
+
+bool Babylon::Char::is_Other_Uppercase() const throw (Block_Error)
+{
+    return Dictionary::instance()->is_Other_Uppercase(my_value);
+}
+
+bool Babylon::Char::is_Noncharacter_Code_Point() const throw (Block_Error)
+{
+    return Dictionary::instance()->is_Noncharacter_Code_Point(my_value);
+}
+
+bool Babylon::Char::is_Other_Grapheme_Extend() const throw (Block_Error)
+{
+    return Dictionary::instance()->is_Other_Grapheme_Extend(my_value);
+}
+
+bool Babylon::Char::is_Grapheme_Link() const throw (Block_Error)
+{
+    return Dictionary::instance()->is_Grapheme_Link(my_value);
+}
+
+bool Babylon::Char::is_IDS_Binary_Operator() const throw (Block_Error)
+{
+    return Dictionary::instance()->is_IDS_Binary_Operator(my_value);
+}
+
+bool Babylon::Char::is_IDS_Trinary_Operator() const throw (Block_Error)
+{
+    return Dictionary::instance()->is_IDS_Trinary_Operator(my_value);
+}
+
+bool Babylon::Char::is_Radical() const throw (Block_Error)
+{
+    return Dictionary::instance()->is_Radical(my_value);
+}
+
+bool Babylon::Char::is_Unified_Ideograph() const throw (Block_Error)
+{
+    return Dictionary::instance()->is_Unified_Ideograph(my_value);
+}
+
+bool Babylon::Char::is_Other_Default_Ignorable_Code_Point() const
+    throw (Block_Error)
+{
+    return Dictionary::instance()->
+	is_Other_Default_Ignorable_Code_Point(my_value);
+}
+
+bool Babylon::Char::is_Deprecated() const throw (Block_Error)
+{
+    return Dictionary::instance()->is_Deprecated(my_value);
+}
+
+bool Babylon::Char::is_Soft_Dotted() const throw (Block_Error)
+{
+    return Dictionary::instance()->is_Soft_Dotted(my_value);
+}
+
+bool Babylon::Char::is_Logical_Order_Exception() const throw (Block_Error)
+{
+    return Dictionary::instance()->is_Logical_Order_Exception(my_value);
+}
+
+bool Babylon::Char::is_Other_ID_Start() const throw (Block_Error)
+{
+    return Dictionary::instance()->is_Other_ID_Start(my_value);
+}
+
+// Derived Properties
+bool Babylon::Char::is_Math() const throw (Block_Error)
+{
+    return Dictionary::instance()->is_Math(my_value);
+}
+
+bool Babylon::Char::is_Alphabetic() const throw (Block_Error)
+{
+    return Dictionary::instance()->is_Alphabetic(my_value);
+}
+
+bool Babylon::Char::is_Lowercase() const throw (Block_Error)
+{
+    return Dictionary::instance()->is_Lowercase(my_value);
+}
+
+bool Babylon::Char::is_Uppercase() const throw (Block_Error)
+{
+    return Dictionary::instance()->is_Uppercase(my_value);
+}
+
+bool Babylon::Char::is_ID_Start() const throw (Block_Error)
+{
+    return Dictionary::instance()->is_ID_Start(my_value);
+}
+
+bool Babylon::Char::is_ID_Continue() const throw (Block_Error)
+{
+    return Dictionary::instance()->is_ID_Continue(my_value);
+}
+
+bool Babylon::Char::is_XID_Start() const throw (Block_Error)
+{
+    return Dictionary::instance()->is_XID_Start(my_value);
+}
+
+bool Babylon::Char::is_XID_Continue() const throw (Block_Error)
+{
+    return Dictionary::instance()->is_XID_Continue(my_value);
+}
+
+bool Babylon::Char::is_Default_Ignorable_Code_Point() const
+    throw (Block_Error)
+{
+    return Dictionary::instance()->is_Default_Ignorable_Code_Point(my_value);
+}
+
+bool Babylon::Char::is_Grapheme_Extend() const throw (Block_Error)
+{
+    return Dictionary::instance()->is_Grapheme_Extend(my_value);
+}
+
+bool Babylon::Char::is_Grapheme_Base() const throw (Block_Error)
+{
+    return Dictionary::instance()->is_Grapheme_Base(my_value);
+}
+
+bool Babylon::Char::is_FC_NFKC_Closure() const throw (Block_Error)
+{
+    return Dictionary::instance()->is_FC_NFKC_Closure(my_value);
+}
+
+bool Babylon::Char::is_Full_Composition_Exclusion() const throw (Block_Error)
+{
+    return Dictionary::instance()->is_Full_Composition_Exclusion(my_value);
+}
+
+bool Babylon::Char::is_NFD_QuickCheck() const throw (Block_Error)
+{
+    return Dictionary::instance()->is_NFD_QuickCheck(my_value);
+}
+
+bool Babylon::Char::is_NFC_QuickCheck() const throw (Block_Error)
+{
+    return Dictionary::instance()->is_NFC_QuickCheck(my_value);
+}
+
+bool Babylon::Char::is_NFKD_QuickCheck() const throw (Block_Error)
+{
+    return Dictionary::instance()->is_NFKD_QuickCheck(my_value);
+}
+
+bool Babylon::Char::is_NFKC_QuickCheck() const throw (Block_Error)
+{
+    return Dictionary::instance()->is_NFKC_QuickCheck(my_value);
+}
+
+bool Babylon::Char::is_Expands_On_NFD() const throw (Block_Error)
+{
+    return Dictionary::instance()->is_Expands_On_NFD(my_value);
+}
+
+bool Babylon::Char::is_Expands_On_NFC() const throw (Block_Error)
+{
+    return Dictionary::instance()->is_Expands_On_NFC(my_value);
+}
+
+bool Babylon::Char::is_Expands_On_NFKD() const throw (Block_Error)
+{
+    return Dictionary::instance()->is_Expands_On_NFKD(my_value);
+}
+
+bool Babylon::Char::is_Expands_On_NFKC() const throw (Block_Error)
+{
+    return Dictionary::instance()->is_Expands_On_NFKC(my_value);
+}
+
+// Further Properties
+bool Babylon::Char::is_Space() const throw (Block_Error)
+{
+    return Dictionary::instance()->is_Space(my_value);
+}
+
+bool Babylon::Char::is_Punctuation() const throw (Block_Error)
+{
+    return Dictionary::instance()->is_Punctuation(my_value);
+}
+
+bool Babylon::Char::is_Line_Separator() const throw (Block_Error)
+{
+    return Dictionary::instance()->is_Line_Separator(my_value);
+}
+
+bool Babylon::Char::is_Paragraph_Separator() const throw (Block_Error)
+{
+    return Dictionary::instance()->is_Paragraph_Separator(my_value);
+}
+
+bool Babylon::Char::is_Currency_Symbol() const throw (Block_Error)
+{
+    return Dictionary::instance()->is_Currency_Symbol(my_value);
+}
+
+bool Babylon::Char::is_Bidi_Left_to_Right() const throw (Block_Error)
+{
+    return Dictionary::instance()->is_Bidi_Left_to_Right(my_value);
+}
+
+bool Babylon::Char::is_Bidi_European_Digit() const throw (Block_Error)
+{
+    return Dictionary::instance()->is_Bidi_European_Digit(my_value);
+}
+
+bool Babylon::Char::is_Bidi_Eur_Num_Separator() const throw (Block_Error)
+{
+    return Dictionary::instance()->is_Bidi_Eur_Num_Separator(my_value);
+}
+
+bool Babylon::Char::is_Bidi_Eur_Num_Terminator() const throw (Block_Error)
+{
+    return Dictionary::instance()->is_Bidi_Eur_Num_Terminator(my_value);
+}
+
+bool Babylon::Char::is_Bidi_Arabic_Digit() const throw (Block_Error)
+{
+    return Dictionary::instance()->is_Bidi_Arabic_Digit(my_value);
+}
+
+bool Babylon::Char::is_Bidi_Common_Separator() const throw (Block_Error)
+{
+    return Dictionary::instance()->is_Bidi_Common_Separator(my_value);
+}
+
+bool Babylon::Char::is_Bidi_Block_Separator() const throw (Block_Error)
+{
+    return Dictionary::instance()->is_Bidi_Block_Separator(my_value);
+}
+
+bool Babylon::Char::is_Bidi_Segment_Separator() const throw (Block_Error)
+{
+    return Dictionary::instance()->is_Bidi_Segment_Separator(my_value);
+}
+
+bool Babylon::Char::is_Bidi_Whitespace() const throw (Block_Error)
+{
+    return Dictionary::instance()->is_Bidi_Whitespace(my_value);
+}
+
+bool Babylon::Char::is_Bidi_Non_spacing_Mark() const throw (Block_Error)
+{
+    return Dictionary::instance()->is_Bidi_Non_spacing_Mark(my_value);
+}
+
+bool Babylon::Char::is_Bidi_Boundary_Neutral() const throw (Block_Error)
+{
+    return Dictionary::instance()->is_Bidi_Boundary_Neutral(my_value);
+}
+
+bool Babylon::Char::is_Bidi_PDF() const throw (Block_Error)
+{
+    return Dictionary::instance()->is_Bidi_PDF(my_value);
+}
+
+bool Babylon::Char::is_Bidi_Embedding_or_Override() const throw (Block_Error)
+{
+    return Dictionary::instance()->is_Bidi_Embedding_or_Override(my_value);
+}
+
+bool Babylon::Char::is_Bidi_Other_Neutral() const throw (Block_Error)
+{
+    return Dictionary::instance()->is_Bidi_Other_Neutral(my_value);
+}
+
+bool Babylon::Char::is_Virama() const throw (Block_Error)
+{
+    return Dictionary::instance()->is_Virama(my_value);
+}
+
+bool Babylon::Char::is_Printable() const throw (Block_Error)
+{
+    return Dictionary::instance()->is_Printable(my_value);
+}
+
+bool Babylon::Char::is_Titlecase() const throw (Block_Error)
+{
+    return Dictionary::instance()->is_Titlecase(my_value);
+}
+
+bool Babylon::Char::is_Private_Use() const throw (Block_Error)
+{
+    return Dictionary::instance()->is_Private_Use(my_value);
+}
+
+bool Babylon::Char::is_Control() const throw (Block_Error)
+{
+    Gen_Cat c = Dictionary::instance()->category(my_value);
+    return (CAT_Zl == c || CAT_Zp == c || CAT_Cc == c || CAT_Cf == c);
+}
+
+
+bool Babylon::Char::is_hangul_L() const throw (Block_Error)
+{
+    if ((0x1100 <= my_value && 0x1159 >= my_value) ||
+	0x115f == my_value) return 1;
+    return 0;
+}
+
+bool Babylon::Char::is_hangul_V() const throw (Block_Error)
+{
+    if (0x1160 <= my_value && 0x11A2 >= my_value) return 1;
+    return 0;
+}
+
+bool Babylon::Char::is_hangul_T() const throw (Block_Error)
+{
+    if (0x11A8 <= my_value && 0x11F9 >= my_value) return 1;
+    return 0;
+}
+
+bool Babylon::Char::is_hangul_LV() const throw (Block_Error)
+{
+    if (!(0xAC00 <= my_value && 0xD788 >= my_value)) return 0;
+    return (Dictionary::instance()->decompose(my_value).length() == 2);
+}
+
+bool Babylon::Char::is_hangul_LVT() const throw (Block_Error)
+{
+    if (!(0xAC01 <= my_value && 0xD7A3 >= my_value)) return 0;
+    return (Dictionary::instance()->decompose(my_value).length() == 3);
+}
+
+Babylon::Char::Char(const std::string & s, size_t & pos,
+		    const std::string format)
+{
+    pos = convert(s, pos, format);
+}

Index: Dictionary.cc
===================================================================
RCS file: /cvs/fresco/Fresco/Babylon/src/Dictionary.cc,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- Dictionary.cc	29 Mar 2003 01:51:43 -0000	1.15
+++ Dictionary.cc	1 Aug 2003 16:47:15 -0000	1.16
@@ -1,8 +1,8 @@
 /*$Id$
  *
  * This source file is a part of the Berlin Project.
- * Copyright (C) 1999,2000 Tobias Hunger <[email protected]>
- * http://www.berlin-consortium.org
+ * Copyright (C) 1999-2003 Tobias Hunger <[email protected]>
+ * http://www.fresco.org
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -20,438 +20,722 @@
[...1345 lines suppressed...]
+         i != my_data.end();
+         ++i)
+	if (i->my_block)
+	    delete i->my_block;
     
-    m_data.clear();
-    delete m_undef_block;
-};
-
-
-Dictionary::Block::Block() {}
-
-
-Dictionary::Block::~Block() {}
-
-
-void Dictionary::Block::clean() {}
+    my_data.clear();
+    delete my_undef_block;
+}

Index: Makefile.in
===================================================================
RCS file: /cvs/fresco/Fresco/Babylon/src/Makefile.in,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -d -r1.27 -r1.28
--- Makefile.in	4 Apr 2003 22:09:57 -0000	1.27
+++ Makefile.in	1 Aug 2003 16:47:15 -0000	1.28
@@ -34,9 +34,10 @@
 LDFLAGS		+= $(SO_LDFLAGS)
 CPPFLAGS        += -DRC_MODULEPATH='"$(libdir)/Babylon"'
 
-SRC		:= traits.cc String.cc Char.cc Dictionary.cc utils.cc \
-                   vis_iterator.cc
-HDR		:= $(patsubst $(hdir)/%, %, $(wildcard $(hdir)/*.hh))
+SRC		:= Dictionary.cc Char.cc exceptions.cc traits.cc String.cc \
+		   Boundaries.cc
+HDR		:= $(patsubst $(hdir)/%, %, $(wildcard $(hdir)/*.hh)) \
+		   $(patsubst $(hdir)/%, %, $(wildcard $(hdir)/internal/*.hh))
 DEP		:= $(patsubst %.cc, %.d, $(SRC))
 OBJ		:= $(patsubst %.cc, %.o, $(SRC))
 HSYN		:= $(patsubst %, %.syn, $(HDR))
@@ -63,27 +64,23 @@
 
 depend: $(DEP)
 
-build-tests:
-
-run-tests:
-
 xref:	$(docdir)/sxr/Babylon.xref $(docdir)/sxr/Babylon.syn
 
 doc:	$(MANUAL)
 
 $(docdir)/sxr/Babylon.xref:	$(XREF)
 	@echo linking xref files together
-	mkdir -p $(docdir)/sxr
-	compile-xref -o $@ $^
+	@mkdir -p $(docdir)/sxr
+	@compile-xref -o $@ $^
 
 $(docdir)/sxr/Babylon.syn:	$(SSYN) $(HSYN)
 	@echo linking synopsis files together
-	mkdir -p $(docdir)/sxr
-	$(SYNOPSIS) -o $@ $^
+	@mkdir -p $(docdir)/sxr
+	@$(SYNOPSIS) -o $@ $^
 
 $(MANUAL):	$(HSYN)
 	@echo formatting $(@F)
-	$(SYNOPSIS) -c ../config/synopsis.py -Wc,formatter=HTML -o $@ $(HSYN)
+	@$(SYNOPSIS) -c ../config/synopsis.py -Wc,formatter=HTML -o $@ $(HSYN)
 	touch $@
 
 install:	all
@@ -91,7 +88,7 @@
 	$(SHTOOL) install -C -m 755 $(TARGET) $(DESTDIR)$(libdir)
 	$(SHTOOL) mkdir -f -p -m 755 $(DESTDIR)$(includedir)/Babylon
 	for header in $(HDR); do \
-	  $(SHTOOL) install -C -m 644 $(hdir)/$$header $(DESTDIR)$(includedir)/Babylon; \
+	    $(SHTOOL) install -C -m 644 $(hdir)/$$header $(DESTDIR)$(includedir)/Babylon; \
 	done
 	$(SHTOOL) mkdir -f -p -m 755 $(DESTDIR)$(bindir)
 	$(SHTOOL) install -C -m 755 ../config/Babylon-config $(DESTDIR)$(bindir)
@@ -106,13 +103,17 @@
 	rm -rf $(DESTDIR)$(includedir)/Babylon
 	rm -f $(DESTDIR)$(libdir)/libBabylon.so
 
+build-tests: all
+
+run-tests: build-tests
+
 clean:	
 	rm -f $(TARGET)
 	rm -f *.o *.d *.syn
 
 distclean:	clean
 	rm -f Makefile ../include/Babylon/acconfig.hh \
-          ../bin/Babylon-config
+		../bin/Babylon-config
 
 maintainer-clean: distclean
 
@@ -122,15 +123,15 @@
 
 %.o:	%.cc
 	@echo compiling $(@F)
-	$(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $< -o $@
+	@$(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $< -o $@
 
 %.hh.syn %.hh.xref:	%.hh
 	@echo parsing $(^F)
-	$(SYNOPSIS) -c ../config/synopsis.py -Wc,parser=Fresco,linker=Fresco $(patsubst -I%, -I%, $(CPPFLAGS)) -Wp,-x,$(<F).xref -o $*.hh.syn $?
+	@$(SYNOPSIS) -c ../config/synopsis.py -Wc,parser=Fresco,linker=Fresco $(patsubst -I%, -I%, $(CPPFLAGS)) -Wp,-x,$(<F).xref -o $*.hh.syn $?
 
 %.cc.syn %.cc.xref:	%.cc
 	@echo parsing $(^F)
-	$(SYNOPSIS) -c ../config/synopsis.py -Wc,parser=Fresco,linker=Fresco $(patsubst -I%, -I%, $(CPPFLAGS)) -Wp,-x,$(<F).xref -o $*.cc.syn $?
+	@$(SYNOPSIS) -c ../config/synopsis.py -Wc,parser=Fresco,linker=Fresco $(patsubst -I%, -I%, $(CPPFLAGS)) -Wp,-x,$(<F).xref -o $*.cc.syn $?
 
 ifneq (,$(findstring depend, $(MAKECMDGOALS)))
 $(DEP): %.d:	.FORCE

Index: String.cc
===================================================================
RCS file: /cvs/fresco/Fresco/Babylon/src/String.cc,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- String.cc	31 May 2002 23:42:14 -0000	1.12
+++ String.cc	1 Aug 2003 16:47:15 -0000	1.13
@@ -1,8 +1,8 @@
 /*$Id$
  *
- * This source file is a part of the Berlin Project.
- * Copyright (C) 1999,2000 Tobias Hunger <[email protected]>
- * http://www.berlin-consortium.org
+ * This source file is a part of the Fresco Project.
+ * Copyright (C) 1999-2003 Tobias Hunger <[email protected]>
+ * http://www.fresco.org
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
[...964 lines suppressed...]
+	std::cerr << "none";
+    else if (NORM_D == my_norm)
+	std::cerr << "D";
+    else if (NORM_C == my_norm)
+	std::cerr << "C";
+    else if (NORM_KD == my_norm)
+	std::cerr << "KD";
+    else if (NORM_KC == my_norm)
+	std::cerr << "KC";
+    else
+	std::cerr << "UNKNOWN";
 
-bool Babylon::Paragraph_eq::operator() (const Paragraph & p1,
-					 const Paragraph & p2) {
-    return p1.begin == p2.begin && p1.end == p2.end;
+    std::cerr << " (" << length() << ")  >";
+    for(const_iterator i = begin(); i != end(); ++i)
+	std::cerr << i->value() << " ";
+    std::cerr << "<" << std::dec << std::endl;
 }

Index: traits.cc
===================================================================
RCS file: /cvs/fresco/Fresco/Babylon/src/traits.cc,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- traits.cc	7 Nov 2002 00:01:01 -0000	1.1
+++ traits.cc	1 Aug 2003 16:47:15 -0000	1.2
@@ -1,8 +1,8 @@
 /*$Id$
  *
- * This source file is a part of the Berlin Project.
- * Copyright (C) 1999,2000 Tobias Hunger <[email protected]>
- * http://www.berlin-consortium.org
+ * This source file is a part of the Fresco Project.
+ * Copyright (C) 1999-2003 Tobias Hunger <[email protected]>
+ * http://www.fresco.org
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -22,8 +22,7 @@
 
 #if __GNUC__ >= 3
 
-#include <Babylon/Char.hh>
-#include <Babylon/traits.hh>
+#include <Babylon/internal/traits.hh>
 
 #include <cstring>
 

--- vis_iterator.cc DELETED ---