Core: Add serialization interface
Former-commit-id: cfa749dba1b6f23ef8f38519e0bc9ad9492e3db3
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#include <Nazara/Core/Stream.hpp>
|
||||
#include <Nazara/Core/String.hpp>
|
||||
#include <Nazara/Core/Debug.hpp>
|
||||
|
||||
namespace Nz
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
///TODO: Réécrire une bonne partie des algorithmes employés (Relu jusqu'à 3538)
|
||||
|
||||
#include <Nazara/Core/String.hpp>
|
||||
#include <Nazara/Core/Algorithm.hpp>
|
||||
#include <Nazara/Core/Config.hpp>
|
||||
#include <Nazara/Core/Error.hpp>
|
||||
#include <Nazara/Core/Unicode.hpp>
|
||||
@@ -4208,6 +4209,26 @@ namespace Nz
|
||||
return emptyString;
|
||||
}
|
||||
|
||||
bool Serialize(OutputStream* output, const String& string)
|
||||
{
|
||||
if (!Serialize<UInt32>(output, string.GetSize()))
|
||||
return false;
|
||||
|
||||
output->Write(string.GetConstBuffer(), string.GetSize());
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Unserialize(InputStream* input, String* string)
|
||||
{
|
||||
UInt32 size;
|
||||
if (!Unserialize(input, &size))
|
||||
return false;
|
||||
|
||||
string->Resize(size);
|
||||
input->Read(string->GetBuffer(), size);
|
||||
return true;
|
||||
}
|
||||
|
||||
const unsigned int String::npos(std::numeric_limits<unsigned int>::max());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user