+ }
+
+ public partial class MDatabase : IComparable<MDatabase>
+ {
+ private bool read_range (MStreamReader mst, out int from, out int to)
+ {
+ if (! mst.ReadInteger (out from))
+ {
+ to = from;
+ return false;
+ }
+ to = mst.Read ();
+ if (to < 0)
+ return false;
+ if (to != '-')
+ {
+ to = from;
+ return true;
+ }
+ return mst.ReadInteger (out to);
+ }
+
+ private MCharTable load_char_table (MCharTable table)
+ {
+ MSymbol type = tag[1];
+
+ using (FileStream stream = FileInfo.OpenRead ())
+ {
+ MStreamReader mst = new MStreamReader (stream, ';', true);
+ int c, from, to;
+
+ while ((c = mst.Peek ()) >= 0)
+ {
+ if (c != '#'
+ && read_range (mst, out from, out to)
+ && mst.SkipSpace (out c))
+ {
+ object value = null;
+
+ if (type == MSymbol.integer)
+ {
+ int i;
+ if (mst.ReadInteger (out i))
+ value = i;
+ }
+ else if (type == MSymbol.symbol)
+ {
+ MSymbol sym;
+ if (mst.ReadSymbol (out sym, -1))
+ value = sym;
+ }
+ else if (type == MSymbol.mtext)
+ {
+ MText mt;
+ if (mst.ReadMText (out mt))
+ value = mt;
+ }
+ else if (type == MSymbol.plist)
+ {
+ value = new MPlist (mst);
+ }
+ else if (type == MSymbol.mstring)
+ {
+ string str;
+ if (mst.ReadString (out str))
+ value = str;
+ }
+ if (value != null)
+ table[from, to] = value;
+ }
+ mst.ForwardLine ();
+ }
+ }
+ return table;
+ }
+
+ public object Load (MCharTable table)
+ {
+ if (loader != null || Info.Format != Mchar_table)
+ throw new ArgumentException ("Not a database of CharTable type");
+ if (! update_status ())
+ throw new Exception ("Database invalid");
+ return load_char_table (table);