#include "Serializer.hpp" namespace sprawl { namespace serialization { SerializerBase& SerializerBase::operator%(SerializationData<unsigned int>&& var) { serialize(var.val, sizeof(var.val), var.name, var.PersistToDB); return *this; } SerializerBase& SerializerBase::operator%(SerializationData<unsigned long int>&& var) { serialize(var.val, sizeof(var.val), var.name, var.PersistToDB); return *this; } SerializerBase& SerializerBase::operator%(SerializationData<unsigned char>&& var) { serialize(var.val, sizeof(var.val), var.name, var.PersistToDB); return *this; } SerializerBase& SerializerBase::operator%(SerializationData<unsigned char* >&& var) { uint32_t len = (uint32_t)strlen(reinterpret_cast<char*>(var.val)); if(IsBinary()) { *this % prepare_data(len, var.name, false); } serialize(var.val, len, var.name, var.PersistToDB); return *this; } SerializerBase& SerializerBase::operator%(SerializationData<bool>&& var) { serialize(var.val, sizeof(var.val), var.name, var.PersistToDB); return *this; } SerializerBase& SerializerBase::operator%(SerializationData<std::vector<bool>::reference>&& var) { bool val = var.val; serialize(val, sizeof(bool), var.name, var.PersistToDB); return *this; } SerializerBase& SerializerBase::operator%(SerializationData<int>&& var) { serialize(var.val, sizeof(var.val), var.name, var.PersistToDB); return *this; } SerializerBase& SerializerBase::operator%(SerializationData<long int>&& var) { serialize(var.val, sizeof(var.val), var.name, var.PersistToDB); return *this; } SerializerBase& SerializerBase::operator%(SerializationData<long long int>&& var) { serialize(var.val, sizeof(var.val), var.name, var.PersistToDB); return *this; } SerializerBase& SerializerBase::operator%(SerializationData<unsigned long long int>&& var) { serialize(var.val, sizeof(var.val), var.name, var.PersistToDB); return *this; } SerializerBase& SerializerBase::operator%(SerializationData<unsigned short int>&& var) { serialize(var.val, sizeof(var.val), var.name, var.PersistToDB); return *this; } SerializerBase& SerializerBase::operator%(SerializationData<long double>&& var) { serialize(var.val, sizeof(var.val), var.name, var.PersistToDB); return *this; } SerializerBase& SerializerBase::operator%(SerializationData<short int>&& var) { serialize(var.val, sizeof(var.val), var.name, var.PersistToDB); return *this; } SerializerBase& SerializerBase::operator%(SerializationData<float>&& var) { serialize(var.val, sizeof(var.val), var.name, var.PersistToDB); return *this; } SerializerBase& SerializerBase::operator%(SerializationData<double>&& var) { serialize(var.val, sizeof(var.val), var.name, var.PersistToDB); return *this; } SerializerBase& SerializerBase::operator%(SerializationData<char>&& var) { serialize(var.val, sizeof(var.val), var.name, var.PersistToDB); return *this; } SerializerBase& SerializerBase::operator%(SerializationData<char* >&& var) { uint32_t len = (uint32_t)strlen(var.val); if(IsBinary()) { *this % prepare_data(len, var.name, false); } serialize(var.val, len, var.name, var.PersistToDB); return *this; } /*virtual*/ SerializerBase& SerializerBase::operator%(BinaryData&& var) { uint32_t len = var.size; serialize(var.val, len, var.name, var.PersistToDB); return *this; } sprawl::serialization::SerializerBase& SerializerBase::operator%(SerializationData<std::string>&& var) { uint32_t len = (uint32_t)var.val.length(); if(IsBinary()) { *this % prepare_data(len, var.name, false); } serialize(&var.val, len, var.name, var.PersistToDB); return *this; } sprawl::serialization::SerializerBase& SerializerBase::operator%(SerializationData<sprawl::String>&& var) { uint32_t len = (uint32_t)var.val.length(); if(IsBinary()) { *this % prepare_data(len, var.name, false); } serialize(&var.val, len, var.name, var.PersistToDB); return *this; } SerializerBase& SerializerBase::operator%(SerializationData<class Serializer> &&){ SPRAWL_UNIMPLEMENTED_BASE_CLASS_METHOD; return *this; } SerializerBase& SerializerBase::operator%(SerializationData<class Deserializer> &&){ SPRAWL_UNIMPLEMENTED_BASE_CLASS_METHOD; return *this; } SerializerBase& SerializerBase::operator%(SerializationData<class BinarySerializer> &&){ SPRAWL_UNIMPLEMENTED_BASE_CLASS_METHOD; return *this; } SerializerBase& SerializerBase::operator%(SerializationData<class BinaryDeserializer> &&){ SPRAWL_UNIMPLEMENTED_BASE_CLASS_METHOD; return *this; } SerializerBase& SerializerBase::operator%(SerializationData<class JSONSerializer> &&){ SPRAWL_UNIMPLEMENTED_BASE_CLASS_METHOD; return *this; } SerializerBase& SerializerBase::operator%(SerializationData<class JSONDeserializer> &&){ SPRAWL_UNIMPLEMENTED_BASE_CLASS_METHOD; return *this; } SerializerBase& SerializerBase::operator%(SerializationData<class YAMLSerializer> &&){ SPRAWL_UNIMPLEMENTED_BASE_CLASS_METHOD; return *this; } SerializerBase& SerializerBase::operator%(SerializationData<class YAMLDeserializer> &&){ SPRAWL_UNIMPLEMENTED_BASE_CLASS_METHOD; return *this; } SerializerBase& SerializerBase::operator%(SerializationData<class MongoSerializer> &&){ SPRAWL_UNIMPLEMENTED_BASE_CLASS_METHOD; return *this; } SerializerBase& SerializerBase::operator%(SerializationData<class MongoDeserializer> &&){ SPRAWL_UNIMPLEMENTED_BASE_CLASS_METHOD; return *this; } void SerializerBase::StartArray(sprawl::String const& , uint32_t&, bool){} void SerializerBase::EndArray(){} uint32_t SerializerBase::StartObject(sprawl::String const& , bool){ return 0; } void SerializerBase::EndObject(){} uint32_t SerializerBase::StartMap(sprawl::String const& s, bool b){ return StartObject(s, b); } void SerializerBase::EndMap(){ EndObject(); } sprawl::String SerializerBase::GetNextKey(){ return ""; } SerializerBase::StringSet SerializerBase::GetDeletedKeys(sprawl::String const&){ return StringSet(); } SerializerBase* SerializerBase::GetAnother(sprawl::String const&){ SPRAWL_UNIMPLEMENTED_BASE_CLASS_METHOD; return nullptr; } SerializerBase* SerializerBase::GetAnother(){ SPRAWL_UNIMPLEMENTED_BASE_CLASS_METHOD; return nullptr; } Serializer::~Serializer(){} bool Serializer::IsLoading() { return false; } Serializer::Serializer() { } Deserializer::~Deserializer(){} bool Deserializer::IsLoading() { return true; } Deserializer::Deserializer() { } } }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#4 | 16768 | ShadauxCat |
Improvements to error handling in builds with exceptions disabled: - In debug builds or with SPRAWL_ERRORSTATE_STRICT enabled, ErrorState will output a message to stderr and terminate if Get() is called when an error flag is set. (In release buils or with SPRAWL_ERRORSTATE_PERMISSIVE defined, Get() will return junk memory in this case.) - In debug builds or with SPRAWL_ERRORSTATE_STRICT enabled, ErrorState will output a message to stderr and terminate if its destructor is called without checking the errorstate if an error is present (equivalent to an exception terminating the application if no catch() block is present for it). - On linux builds and when running "Analyze" through visual studio, a warning will be issued if any function returning ErrorState has its return value ignored. (This only applies to builds with exceptions not enabled; when exceptions are enabled no warning is issued) - Many functions that could return ErrorState were having their return values silently ignored in internal sprawl code so the user would not find out about errors if exceptions are disabled; now anything in sprawl code that calls a function returning ErrorState will either handle the error, or (in most cases) surface it back up to the user. - As a positive side-effect of the warnings for ignoring ErrorState, several constructors that were capable of throwing exceptions are no longer capable of doing so. #review-16769 |
||
#3 | 16378 | ShadauxCat |
New exception framework, phase one. Added new class, ErrorState, for handling errors when exceptions are disabled. When exceptions are enabled, ErrorState<T> is an alias for T. When they're disabled, ErrorState<T> additionally encodes an error code, and will have junk data (and probably a crash) if an error is returned and not checked before the data is used. ErrorState<T> is implicitly convertible to and from T, so applications that don't care about errors can code like they don't exist... Phase two will involve overloading operators on ErrorState so that things that return ErrorState can still function as much as possible like they do when exceptions are enabled. #review-16379 |
||
#2 | 14783 | ShadauxCat |
Style corrections (placement of const) #review-14784 |
||
#1 | 11496 | ShadauxCat | Initial checkin: Current states for csbuild and libSprawl |