MCPcopy Create free account
hub / github.com/danielaparker/jsoncons / escape

Function escape

include/jsoncons_ext/jsonpointer/jsonpointer.hpp:44–66  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

42
43 template <typename CharT,typename Allocator=std::allocator<CharT>>
44 std::basic_string<CharT,std::char_traits<CharT>,Allocator> escape(jsoncons::basic_string_view<CharT> s, const Allocator& = Allocator())
45 {
46 std::basic_string<CharT,std::char_traits<CharT>,Allocator> result;
47
48 for (auto c : s)
49 {
50 if (JSONCONS_UNLIKELY(c == '~'))
51 {
52 result.push_back('~');
53 result.push_back('0');
54 }
55 else if (JSONCONS_UNLIKELY(c == '/'))
56 {
57 result.push_back('~');
58 result.push_back('1');
59 }
60 else
61 {
62 result.push_back(c);
63 }
64 }
65 return result;
66 }
67
68 template <typename CharT>
69 std::basic_string<CharT> escape_string(const std::basic_string<CharT>& s)

Callers 2

flatten_Function · 0.85
from_diffFunction · 0.85

Calls 1

push_backMethod · 0.45

Tested by

no test coverage detected