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

Function to_basic_string

include/jsoncons_ext/jsonpath/json_location.hpp:863–888  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

861
862 template <typename CharT,typename Allocator = std::allocator<CharT>>
863 std::basic_string<CharT, std::char_traits<CharT>, Allocator> to_basic_string(const basic_json_location<CharT,Allocator>& location,
864 const Allocator& alloc = Allocator())
865 {
866 std::basic_string<CharT, std::char_traits<CharT>, Allocator> buffer(alloc);
867
868 buffer.push_back('$');
869 for (const auto& element : location)
870 {
871 if (element.has_name())
872 {
873 buffer.push_back('[');
874 buffer.push_back('\'');
875 jsoncons::jsonpath::escape_string(element.name().data(), element.name().size(), buffer);
876 buffer.push_back('\'');
877 buffer.push_back(']');
878 }
879 else
880 {
881 buffer.push_back('[');
882 jsoncons::from_integer(element.index(), buffer);
883 buffer.push_back(']');
884 }
885 }
886
887 return buffer;
888 }
889
890 template <typename Json>
891 std::pair<Json*,bool> replace(Json& root, const basic_json_location<typename Json::char_type>& location, const Json& value,

Callers 2

to_stringFunction · 0.70
to_wstringFunction · 0.70

Calls 8

from_integerFunction · 0.85
has_nameMethod · 0.80
escape_stringFunction · 0.70
push_backMethod · 0.45
dataMethod · 0.45
nameMethod · 0.45
sizeMethod · 0.45
indexMethod · 0.45

Tested by

no test coverage detected