MCPcopy Create free account
hub / github.com/ClickHouse/ClickHouse / find

Method find

base/poco/JSON/src/Query.cpp:101–169  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

99
100
101Var Query::find(const std::string& path) const
102{
103 Var result = _source;
104 StringTokenizer tokenizer(path, ".");
105 for (StringTokenizer::Iterator token = tokenizer.begin(); token != tokenizer.end(); token++)
106 {
107 if (!result.isEmpty())
108 {
109 std::vector<int> indexes;
110 RegularExpression::MatchVec matches;
111 int firstOffset = -1;
112 int offset = 0;
113 RegularExpression regex("\\[([0-9]+)\\]");
114 while (regex.match(*token, offset, matches) > 0)
115 {
116 if (firstOffset == -1)
117 {
118 firstOffset = static_cast<int>(matches[0].offset);
119 }
120 std::string num = token->substr(matches[1].offset, matches[1].length);
121 indexes.push_back(NumberParser::parse(num));
122 offset = static_cast<int>(matches[0].offset + matches[0].length);
123 }
124
125 std::string name(*token);
126 if (firstOffset != -1)
127 {
128 name = name.substr(0, firstOffset);
129 }
130
131 if (name.length() > 0)
132 {
133 if (result.type() == typeid(Object::Ptr))
134 {
135 Object::Ptr o = result.extract<Object::Ptr>();
136 result = o->get(name);
137 }
138 else if (result.type() == typeid(Object))
139 {
140 Object o = result.extract<Object>();
141 result = o.get(name);
142 }
143 else
144 result.empty();
145
146 }
147
148 if (!result.isEmpty() && !indexes.empty())
149 {
150 for (std::vector<int>::iterator it = indexes.begin(); it != indexes.end(); ++it)
151 {
152 if (result.type() == typeid(Array::Ptr))
153 {
154 Array::Ptr array = result.extract<Array::Ptr>();
155 result = array->get(*it);
156 if (result.isEmpty()) break;
157 }
158 else if (result.type() == typeid(Array))

Callers 13

handleMethod · 0.45
syncKeysMethod · 0.45
getMethod · 0.45
getArrayMethod · 0.45
getObjectMethod · 0.45
optValueFunction · 0.45
hasMethod · 0.45
isArrayMethod · 0.45
isNullMethod · 0.45
isObjectMethod · 0.45
Object.hFile · 0.45
argsToConfigFunction · 0.45

Calls 10

parseFunction · 0.50
beginMethod · 0.45
endMethod · 0.45
isEmptyMethod · 0.45
matchMethod · 0.45
push_backMethod · 0.45
lengthMethod · 0.45
typeMethod · 0.45
getMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected