34 pointer::pointer(
const std::string &
pointer)
37 if (pointer[0] ==
'#')
39 build_from_uri_fragment(*utf8::json_string_to_utf8(pointer));
43 build_from_json_string(*utf8::json_string_to_utf8(pointer));
47 void pointer::build_from_uri_fragment(
const std::string &
pointer)
52 if (pointer.size() == 1)
54 m_path.push_back(
token());
58 while (next_token(pointer, start, end))
60 m_path.push_back(translate_uri_token(pointer, start, end));
65 void pointer::build_from_json_string(
const std::string &
pointer)
70 if (pointer.size() == 0)
72 m_path.push_back(
token());
76 while (next_token(pointer, start, end))
78 m_path.push_back(translate_jsonp_token(pointer, start, end));
83 bool pointer::next_token(
const string &
pointer,
size_t &start,
size_t &end)
125 else if (
pointer[start] ==
'1')
140 else if (
pointer[start] ==
'%')
142 if (++start < (end - 1))
144 int c = from_hex(
pointer, start++) * 16;
145 c += from_hex(
pointer, start++);
146 translated +=
static_cast<char>(c);
155 translated +=
pointer[start++];
159 return make_token(translated);
183 else if (
pointer[start] ==
'1')
200 translated +=
pointer[start++];
204 return make_token(translated);
228 int pointer::from_hex(
const string &s,
size_t index)
232 if (c >=
'0' && c <=
'9')
236 else if (c >=
'A' && c <=
'F')
246 pointer::token::token() : m_type(all_e), m_index(0)
278 ostream &NAMESPACE::operator<<(ostream &stream,
const pointer &p)
283 if (t.get_type() == pointer::token::object_e)
285 stream << t.get_name();
287 else if (t.get_type() == pointer::token::array_e)
289 stream << t.get_index();
Specific class of exceptions for IO errors of various types.
token()
Construct a token of type all_e.
#define NAMESPACE
You can change the namespace of the whole library by changing this value.
type_t get_type() const
Get the type of the token.
Tokens in a JSON pointer.
type_t
Different types of pointer tokens.
JSON pointers as per the RFT.
const std::string & get_name() const
Get the name of the slot referenced.
The json_pointer_exception class.
size_t get_index() const
Get the index in the array referenced.
const std::list< token > & get_path() const