Devel Lib
SerializableBool.h
1 #pragma once
2 
3 #include "Serializing/SerializingDefines.h"
4 #include "Serializing/Core/SerializableData.h"
5 #include "Core/Utils/StringUtils.h"
6 
9 namespace Devel::Serializing {
10 #pragma pack(push, 1)
11 
16  template<bool IsHidden = false, typename T = bool>
17  class IBool : public IData<T, IsHidden> {
18  private:
22  bool serialize(IO::CWriteStream &i_oStream) const override {
23  i_oStream.push(this->m_tValue);
24  return true;
25  }
26 
27  private:
31  bool deserialize(IO::CReadStream &i_oStream) override {
32  this->m_tValue = i_oStream.get<T>();
33  return true;
34  }
35 
39  bool deserialize(const char *i_szString) override {
40  this->m_tValue = (StringUtils::ToInt64(i_szString) > 0);
41  return true;
42  }
43 
48  bool deserialize(std::vector<std::string>::const_iterator &i_oIt,
49  const std::vector<std::string>::const_iterator &i_oItEnd) override {
50  this->m_tValue = static_cast<T>(StringUtils::ToInt(*i_oIt));
51 
52  ++i_oIt;
53  return true;
54  }
55 
56  public:
57  CreateSerializeOperators(T, IsHidden);
58  };
59 
60 #pragma pack(pop)
61 }
A class for reading data from a buffer. This class provides functionality to read data from a buffer....
Definition: ReadStream.h:37
T get(const size_t i_nPosition, const bool i_fSetPosition)
Reads a value of type T from the buffer.
Definition: ReadStream.h:344
A class for writing data to a buffer. This class provides functionality to write data to a buffer....
Definition: WriteStream.h:42
void push(const void *i_pBuffer, size_t i_nSize)
Pushes the specified data to the buffer.
Definition: WriteStream.cpp:30
A class representing a boolean value for serialization.
Definition: SerializableBool.h:17
Template class representing a data field.
Definition: SerializableData.h:86
T m_tValue
The value.
Definition: SerializableData.h:78
The namespace encapsulating serializing related functionality in the Devel framework.
long long ToInt64(const std::string &i_sBuffer)
Converts a string to a 64-bit integer.
Definition: StringUtils.h:222
int ToInt(const std::string &i_sBuffer)
Converts a string to an integer.
Definition: StringUtils.h:239