2001-07-19 Jeffrey Stedfast <fejj@ximian.com>
[mono.git] / mcs / class / corlib / System / Char.cs
1 // -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
2 //
3 // System.Char.cs
4 //
5 // Author:
6 //   Miguel de Icaza (miguel@ximian.com)
7 //
8 // (C) Ximian, Inc.  http://www.ximian.com
9 //
10
11 using System.Globalization;
12
13 namespace System {
14         
15         public struct Char : IComparable, IFormattable {
16                 public const char MinValue = (char) 0;
17                 public const char MaxValue = (char) 0xffff;
18                 
19                 // VES needs to know about value.  public is workaround
20                 // so source will compile
21                 public byte value;
22
23                 public int CompareTo (object v)
24                 {
25                         if (!(v is System.Byte))
26                                 throw new ArgumentException ("Value is not a System.Byte");
27
28                         return value - ((byte) v);
29                 }
30
31                 public override bool Equals (object o)
32                 {
33                         if (!(o is System.Byte))
34                                 return false;
35
36                         return ((byte) o) == value;
37                 }
38
39                 public override int GetHashCode ()
40                 {
41                         return value;
42                 }
43
44                 public static double GetNumericValue (char c)
45                 {
46                         if ((c >= 48) && (c <= 57))
47                                 return (double) (c - '0');
48                         return -1;
49                 }
50
51                 public static double GetNumericValue (string s, int index)
52                 {
53                         /* FIXME: implement me */
54                         return -1;
55                 }
56
57                 public static bool IsControl (char c)
58                 {
59                         return ((c > 1) && (c < 32));
60                 }
61
62                 public static bool IsDigit (char c)
63                 {
64                         return ((c >= '0') && (c <= '9'));
65                 }
66
67                 public static bool IsLetter (char c)
68                 {
69                         /*
70                          * FIXME: This is broken, it should support
71                          * the various categories in System.Globalization.UnicodeCategory
72                          */
73                         return ((c >= 65) && (c <= 126));
74                 }
75                 
76                 public TypeCode GetTypeCode ()
77                 {
78                         return TypeCode.Byte;
79                 }
80
81                 public static char Parse (string s)
82                 {
83                         // TODO: Implement me
84                         return (char) 0;
85                 }
86
87                 public static char Parse (string s, IFormatProvider fp)
88                 {
89                         // TODO: Implement me
90                         return (char) 0;
91                 }
92
93                 public static char Parse (string s, NumberStyles style, IFormatProvider fp)
94                 {
95                         // TODO: Implement me
96                         return (char) 0;
97                 }
98
99                 public static char ToLower (char c)
100                 {
101                         // FIXME: make me unicode aware
102                         return (c >= 'A' && c <= 'Z') ? (char) (c + 33) : c;
103                 }
104
105                 public static char ToUpper (char c)
106                 {
107                         // FIXME: make me unicode aware
108                         return (char) ((c >= 'a' && c <= 'z') ? c - 33 : c);
109                 }
110
111                 public override string ToString ()
112                 {
113                         // TODO: Implement me
114
115                         return "";
116                 }
117
118                 public string ToString (IFormatProvider fp)
119                 {
120                         // TODO: Implement me.
121                         return "";
122                 }
123
124                 public string ToString (string format)
125                 {
126                         // TODO: Implement me.
127                         return "";
128                 }
129
130                 public string ToString (string format, IFormatProvider fp)
131                 {
132                         // TODO: Implement me.
133                         return "";
134                 }
135         }
136 }