//---------------------------------------------------------------------
//
// Copyright (C) 2004 Yingle Jia
//
// Permission to copy, use, modify, sell and distribute this software is
// granted provided this copyright notice appears in all copies.
// This software is provided "as is" without express or implied warranty,
// and with no claim as to its suitability for any purpose.
//
#include "stdafx.h"
namespace Acf {
//---------------------------------------------------------------------
// struct SByte
//
// Static Methods
/*static*/ sbyte SByte::Parse(String* s, IFormatProvider* provider)
{
return Parse(s, NumberStyles::Integer, provider);
}
/*static*/ sbyte SByte::Parse(String* s, NumberStyles style, IFormatProvider* provider)
{
int value = Int32::Parse(s, style, provider);
if (value < SByte::MinValue || value > SByte::MaxValue)
throw OverflowException();
return (sbyte)value;
}
/*static*/ bool SByte::TryParse(String* s, sbyte* result)
{
return TryParse(s, NumberStyles::Integer, null, result);
}
/*static*/ bool SByte::TryParse(String* s, NumberStyles style, IFormatProvider* provider,
sbyte* result)
{
int n;
if (!Int32::TryParse(s, style, provider, &n))
return false;
if (n < SByte::MinValue || n > SByte::MaxValue)
return false;
*result = (sbyte)n;
return true;
}
// Methods
int SByte::GetHashCode()
{
return this->Value;
}
StringPtr SByte::ToString(IFormatProvider* provider)
{
return ToString((String*)null, provider);
}
StringPtr SByte::ToString(String* format, IFormatProvider* provider)
{
return Int32(this->Value).ToString(format, provider);
}
StringPtr SByte::ToString(const wchar_t* format, IFormatProvider* provider)
{
return ToString(str(format), provider);
}
// Operators
SByte::operator sbyte() const
{
return this->Value;
}
SByte::operator sbyte&()
{
return this->Value;
}
sbyte* SByte::operator&()
{
return &this->Value;
}
//---------------------------------------------------------------------
// class Boxed<SByte>
// Methods
//
// Object Members
//
/*override*/ bool Boxed<SByte>::Equals(Object* obj)
{
Boxed<SByte>* o = dynamic_cast<Boxed<SByte>*>(obj);
if (o == null)
return false;
else
return (this->Value == o->Value);
}
/*override*/ int Boxed<SByte>::GetHashCode()
{
return this->Value.GetHashCode();
}
/*override*/ StringPtr Boxed<SByte>::ToString()
{
return this->Value.ToString();
}
//
// IFormattable Members
//
/*virtual*/ StringPtr Boxed<SByte>::ToString(String* format, IFormatProvider* provider)
{
return this->Value.ToString(format, provider);
}
} // namespace Acf