Pakman
serialisation.cc
1 #include "serialisation.h"
2 
3 template <>
4 void serialise_scalar_value(const LineString& key, const bool& value,
5  std::ostream& out)
6 {
7  // Store format flags
8  auto fmtflags = out.flags();
9 
10  // Serialise bool value
11  out << std::boolalpha << key.str() << ":" << value << std::endl;
12 
13  // Restore format flags
14  out.flags(fmtflags);
15 }
16 
17 template <>
18 void serialise_scalar_value(const LineString& key, const std::string& value,
19  std::ostream& out)
20 {
21  out << key.str() << ":" << value.size() << ":" << value << std::endl;
22 }
23 
24 template <>
25 void serialise_scalar_value(const LineString& key, const Command& value,
26  std::ostream& out)
27 {
28  serialise_scalar_value(key, value.str(), out);
29 }
30 
31 template <>
33  const TaskHandler& value, std::ostream& out)
34 {
35  serialise_scalar_value(key.str() + ":m_input_string",
36  value.getInputString(), out);
37  serialise_scalar_value(key.str() + ":m_output_string",
38  value.getOutputString(), out);
39  serialise_scalar_value(key.str() + ":m_error_code",
40  value.getErrorCode(), out);
41 }
42 
43 std::ostream& operator<<(std::ostream& out, const LineString& line_string)
44 {
45  out << line_string.str();
46  return out;
47 }
const std::string & str() const
Definition: LineString.cc:45
std::string getOutputString() const
Definition: TaskHandler.cc:53
std::ostream & operator<<(std::ostream &out, const LineString &line_string)
const std::string & str() const
Definition: Command.cc:111
std::string getInputString() const
Definition: TaskHandler.cc:46
int getErrorCode() const
Definition: TaskHandler.cc:60
void serialise_scalar_value(const LineString &key, const value_type &value, std::ostream &out)
Definition: serialisation.h:24