1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
|
template <class T>
struct IsPtr { static const bool VAL=false; };
template <class T>
struct IsPtr<T*> { static const bool VAL=true; };
template <class T, bool>
struct CustomSaver;
template <class T>
struct CustomSaver<T,false>
{
static void Save(const T & data,std::basic_ofstream<TCHAR>& File)
{
data.Save(File);
}
};
template <class T>
struct CustomSaver<T*,true>
{
static void Save(const T * data,std::basic_ofstream<TCHAR>& File)
{
data->Save(File);
}
};
template <class T>
void Custom_Save(const T In,std::basic_ofstream<TCHAR>& File)
{
CustomSaver<T,IsPtr<T>::VAL>::Save(In,File);
}
void Custom_Save (const int In,std::basic_ofstream<TCHAR>& File);
void Custom_Save (const double& In,std::basic_ofstream<TCHAR>& File);
void Custom_Save (const short In,std::basic_ofstream<TCHAR>& File);
void Custom_Save (const TCHAR In,std::basic_ofstream<TCHAR>& File);
void Custom_Save (const std::basic_string<TCHAR>& In,std::basic_ofstream<TCHAR>& File);
void Custom_Save (const bool In,std::basic_ofstream<TCHAR>& File);
template <class X>
void Custom_Save(const std::vector<X>& In,std::basic_ofstream<TCHAR>& File)
{
int l=In.size();
Custom_Save(l,File);
for (int n=0;n<l;++n)
{
Custom_Save(In[n],File);
}
}
template <class X,class Y>
void Custom_Save(const std::map<X,Y>& In,std::basic_ofstream<TCHAR>& File)
{
int l=In.size();
Custom_Save(l,File);
std::map<X,Y>::const_iterator l=In.end();
for (std::map<X,Y>::const_iterator i=In.begin();i!=l;++i)
{
Custom_Save(i->first,File);
Custom_Save(i->second,File);
}
}
template <class X>
void Custom_Save(const std::set<X>& In,std::basic_ofstream<TCHAR>& File)
{
int l=In.size();
Custom_Save(l,File);
std::set<X>::const_iterator l=In.end();
for (std::set<X>::const_iterator i=In.begin();i!=l;++i)
{
Custom_Save(*i,File);
}
}
template <class X>
void Custom_Save(const std::list<X>& In,std::basic_ofstream<TCHAR>& File)
{
int l=In.size();
Custom_Save(l,File);
std::list<X>::const_iterator l=In.end();
for (std::list<X>::const_iterator i=In.begin();i!=l;++i)
{
Custom_Save(*i,File);
}
}
| |