7#include <unordered_map>
10#include <shared_mutex>
48 void add(
const std::string& ID,
const std::string& value);
58 void add(
const std::string& ID,
const std::string& value,
size_t idx);
67 void edit(
const std::string& ID,
const std::string& value,
size_t idx);
74 std::string
get(
const std::string& ID);
80 std::vector<std::string>
split(
const std::string& str);
86 void clear(
const std::string& ID);
105 Serializer() =
default;
106 ~Serializer() =
default;
109 std::shared_mutex mtx;
112 Serializer(
const Serializer&) =
delete;
113 Serializer& operator=(
const Serializer&) =
delete;
114 Serializer(Serializer&&) =
delete;
115 Serializer& operator=(Serializer&&) =
delete;
void sanitizeString(const std::string &separator, std::string &value)
Project NSCpp.
std::string separator
This string virtually divide the serialized strings.
Definition Serializer.h:97
std::string getSeparator()
Return the separator of the Serializer.
void setSeparator(const std::string &separator)
Set the separator of the Serializer.
std::unordered_map< std::string, std::vector< std::string > > serializedStrings
Unordered map linking the ID of the serialized string and the serialized string.
Definition Serializer.h:102
std::string get(const std::string &ID)
Return the serialized string of the given ID.
static Serializer & getInstance()
Return the current instance of the object or create one if it does not exist.
void add(const std::string &ID, const std::string &value)
Add to the string (given by its ID) the sanitized version of the value, at the end.
void clear(const std::string &ID)
Clear the string given by the ID.
std::vector< std::string > split(const std::string &str)
Return a vector containing the strings obtained after a split with the separator.
void add(const std::string &ID, const std::string &value, size_t idx)
Add to the string (given by its ID) the sanitized version of the value at the given index,...
void edit(const std::string &ID, const std::string &value, size_t idx)
Edit the string (given by its ID) with the serialized version of the value at the given index.