@@ -14,7 +14,7 @@ public unsafe interface IConverter<T>
1414 void Convert ( ref char * dst , char * end , T value , FormatSpec formatSpec ) ;
1515}
1616
17- public unsafe class Converter : IConverter < int > , IConverter < float > , IConverter < string >
17+ public unsafe class Converter : IConverter < int > , IConverter < float > , IConverter < string > , IConverter < byte >
1818{
1919 public static Converter instance = new Converter ( ) ;
2020
@@ -23,6 +23,11 @@ void IConverter<int>.Convert(ref char* dst, char* end, int value, FormatSpec for
2323 ConvertInt ( ref dst , end , value , formatSpec . argWidth , formatSpec . integerWidth , formatSpec . leadingZero ) ;
2424 }
2525
26+ void IConverter < byte > . Convert ( ref char * dst , char * end , byte value , FormatSpec formatSpec )
27+ {
28+ ConvertInt ( ref dst , end , value , formatSpec . argWidth , formatSpec . integerWidth , formatSpec . leadingZero ) ;
29+ }
30+
2631 void IConverter < float > . Convert ( ref char * dst , char * end , float value , FormatSpec formatSpec )
2732 {
2833 if ( formatSpec . fractWidth == 0 )
@@ -191,6 +196,32 @@ public void Format(ref char* dst, char* end, int argIndex, FormatSpec formatSpec
191196 }
192197}
193198
199+ public unsafe struct ArgList4 < T0 , T1 , T2 , T3 > : IArgList
200+ {
201+ public int Count { get { return 4 ; } }
202+ T0 t0 ;
203+ T1 t1 ;
204+ T2 t2 ;
205+ T3 t3 ;
206+ public ArgList4 ( T0 a0 , T1 a1 , T2 a2 , T3 a3 )
207+ {
208+ t0 = a0 ;
209+ t1 = a1 ;
210+ t2 = a2 ;
211+ t3 = a3 ;
212+ }
213+ public void Format ( ref char * dst , char * end , int argIndex , FormatSpec formatSpec )
214+ {
215+ switch ( argIndex )
216+ {
217+ case 0 : ( Converter . instance as IConverter < T0 > ) . Convert ( ref dst , end , t0 , formatSpec ) ; break ;
218+ case 1 : ( Converter . instance as IConverter < T1 > ) . Convert ( ref dst , end , t1 , formatSpec ) ; break ;
219+ case 2 : ( Converter . instance as IConverter < T2 > ) . Convert ( ref dst , end , t2 , formatSpec ) ; break ;
220+ case 3 : ( Converter . instance as IConverter < T3 > ) . Convert ( ref dst , end , t3 , formatSpec ) ; break ;
221+ }
222+ }
223+ }
224+
194225/// <summary>
195226/// Garbage free string formatter
196227/// </summary>
0 commit comments