mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-07-11 22:03:01 -06:00
Core: SizeBySerialize
git-svn-id: svn://ultimatepp.org/upp/trunk@14892 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
3a3e40bf16
commit
6f1bb82054
3 changed files with 29 additions and 19 deletions
|
|
@ -341,6 +341,8 @@ class JsonIO;
|
|||
#include "Color.h"
|
||||
#include "Complex.h"
|
||||
|
||||
#include "Hash.h"
|
||||
|
||||
#include "Util.h"
|
||||
|
||||
#include "Profile.h"
|
||||
|
|
@ -351,7 +353,6 @@ class JsonIO;
|
|||
#include "Convert.h"
|
||||
|
||||
#include "z.h"
|
||||
#include "Hash.h"
|
||||
|
||||
#include "Parser.h"
|
||||
#include "JSON.h"
|
||||
|
|
|
|||
|
|
@ -464,6 +464,33 @@ void SerializeGlobalConfigs(Stream& s);
|
|||
inline void abort() { TerminateProcess(NULL, -1); }
|
||||
#endif
|
||||
|
||||
template <class T>
|
||||
hash_t HashBySerialize(const T& cont)
|
||||
{
|
||||
TimeStop tm;
|
||||
xxHashStream xxh;
|
||||
const_cast<T&>(cont).Serialize(xxh);
|
||||
return xxh.Finish();
|
||||
}
|
||||
|
||||
template <class T>
|
||||
size_t SizeBySerialize(const T& cont)
|
||||
{
|
||||
TimeStop tm;
|
||||
SizeStream szs;
|
||||
const_cast<T&>(cont).Serialize(szs);
|
||||
return szs;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
bool IsEqualBySerialize(const T& a, const T& b)
|
||||
{
|
||||
StringStream sa, sb;
|
||||
const_cast<T&>(a).Serialize(sa);
|
||||
const_cast<T&>(b).Serialize(sb);
|
||||
return sa.GetResult() == sb.GetResult();
|
||||
}
|
||||
|
||||
String Replace(const String& s, const Vector<String>& find, const Vector<String>& replace);
|
||||
String Replace(const String& s, const VectorMap<String, String>& fr);
|
||||
WString Replace(const WString& s, const Vector<WString>& find, const Vector<WString>& replace);
|
||||
|
|
|
|||
|
|
@ -21,24 +21,6 @@ void StreamContainer(Stream& s, T& cont)
|
|||
}
|
||||
}
|
||||
|
||||
template <class T>
|
||||
hash_t HashBySerialize(const T& cont)
|
||||
{
|
||||
TimeStop tm;
|
||||
xxHashStream xxh;
|
||||
const_cast<T&>(cont).Serialize(xxh);
|
||||
return xxh.Finish();
|
||||
}
|
||||
|
||||
template <class T>
|
||||
bool IsEqualBySerialize(const T& a, const T& b)
|
||||
{
|
||||
StringStream sa, sb;
|
||||
const_cast<T&>(a).Serialize(sa);
|
||||
const_cast<T&>(b).Serialize(sb);
|
||||
return sa.GetResult() == sb.GetResult();
|
||||
}
|
||||
|
||||
template <class T>
|
||||
T * Vector<T>::RawAlloc(int& n)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue