AvTranscoder  0.9.4
C++APIforLibav/FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JsonWriter.cpp
Go to the documentation of this file.
1 #include "JsonWriter.hpp"
2 
3 #include <string>
4 #include <sstream>
5 
6 namespace avtranscoder
7 {
8 namespace json
9 {
10 
11 std::string JsonStreamWriter::escapeJsonString(const std::string& input)
12 {
13  std::ostringstream ss;
14  for(std::string::const_iterator iter = input.begin(); iter != input.end(); iter++)
15  {
16  switch(*iter)
17  {
18  case '\\':
19  ss << "\\\\";
20  break;
21  default:
22  ss << *iter;
23  break;
24  }
25  }
26  return ss.str();
27 }
28 
29 template <>
30 JsonObjectStreamWriter& JsonObjectStreamWriter::operator<<(const std::pair<const char*, const char*> pair)
31 {
32  std::string first(pair.first);
33  std::string second(pair.second);
34  addSep() << escapeJsonString(first).c_str() << ':' << escapeJsonString(second).c_str();
35  return *this;
36 }
37 
38 template <>
40 {
41  stream << (value ? "true" : "false");
42  return *this;
43 }
44 template <>
46 {
47  stream << '"' << string << '"';
48  return *this;
49 }
50 template <>
52 {
53  stream << "null";
54  return *this;
55 }
56 }
57 }
To manage 'null' element in JSON.
Definition: JsonWriter.hpp:17
std::string escapeJsonString(const std::string &input)
Definition: JsonWriter.cpp:11
Based class to write element to a stream.
Definition: JsonWriter.hpp:24
JsonStreamWriter & operator<<(T value)
Definition: JsonWriter.hpp:46
Write an object to a stream.
Definition: JsonWriter.hpp:84
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy