//You may include <string.h> optionally, but you wouldn't like to, because this header already uses that thing.
#ifndef _INC_STRING
#include <string.h>
#endif
#ifndef _INC_STDLIB
#include <stdlib.h>
#endif
namespace Emulate
{
namespace NET
{
namespace System
{
//WARNING! this thing is just to EMULATE .net, so Object class is NO NEEDED and UNSTABLE! so, please DON'T USE IT!
class Object
{
private:
void *Anyvalue;
int Anylen;
public:
Object()
{
Anyvalue = malloc(sizeof(char));
Anylen = 1;
}
Object(void *anything)
{
char *chrptr = (char *)anything;
int i;
for(i=0;chrptr[i] != 0;i++);
Anylen = i;
Anyvalue = malloc(sizeof(char) * (Anylen + 1));
}
Object(Object &T)
{
Anyvalue = malloc(T.Anylen + 1);
Anylen = T.Anylen;
}
int GetHashCode()
{
char *cp = (char *)this->Anyvalue;
int hc = cp[0];
for(int i=1;i<this->Anylen;i++)
{
hc = hc ^ cp[i];
}
}
bool operator==(Object &a2)
{
if(this->Anylen != a2.Anylen) return false;
else
{
char *v1 = (char *)this->Anyvalue;
char *v2 = (char *)a2.Anyvalue;
int i;
for(i=0;i<this->Anylen;i++)
if(v1[i] != v2[i]) return false;
}
return true;
}
static bool Equals(Object &a1, Object &a2)
{
if(a1.Anylen != a2.Anylen) return false;
else
{
char *v1 = (char *)a1.Anyvalue;
char *v2 = (char *)a2.Anyvalue;
int i;
for(i=0;i<a1.Anylen;i++)
if(v1[i] != v2[i]) return false;
}
return true;
}
bool Equals(Object &a1)
{
return (*this) == a1;
}
bool ReferenceEquals(Object &objA, Object &objB)
{
return objA.Anyvalue == objB.Anyvalue;
}
/*String ToString()
{
//Come again when you make System::String.
}
*/
/*Type GetType()
{
//This function is NOT YET IMPLEMENTED.
//Come again if you make System::Type.
}*/
protected:
void Finalize()
{
free(Anyvalue);
}
Object MemberwiseClone()
{
return Object(*this);
}
};
class String
{
private:
char *Container;
public:
Object *Clone()
{
}
};
}
}
}
#ifdef USING_EMULATE
using Emulate;
#endif
#ifdef USING_NET
using Emulate::NET;
#endif
근데 이 방식이 안전할라나......