-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathjss_string.cpp
More file actions
31 lines (30 loc) · 838 Bytes
/
jss_string.cpp
File metadata and controls
31 lines (30 loc) · 838 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include "jss_string.hpp"
#include "../utility/base64.hpp"
namespace JSON
{
std::ostream& stringify (std::ostream& stream, std::string const& name, std::string const& value, StringificationOptions const& options)
{
SJSON_WRITE_NAME(stream);
stream << '"';
if (!options.strings_are_binary)
{
if (options.escape_strings)
{
for (auto const& i : value)
{
if (i == '"' || i == '\\')
stream.put('\\');
stream.put(i);
}
}
else
stream << value;
}
else
{
encodeBase64 <char, std::basic_string> (stream, value);
}
stream << '"';
return stream;
}
}