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

Method findStart

base/poco/Util/src/JSONConfiguration.cpp:127–239  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

125
126
127JSON::Object::Ptr JSONConfiguration::findStart(const std::string& key, std::string& lastPart)
128{
129 JSON::Object::Ptr currentObject = _object;
130
131 StringTokenizer tokenizer(key, ".");
132 lastPart = tokenizer[tokenizer.count() - 1];
133
134 for(int i = 0; i < tokenizer.count() - 1; ++i)
135 {
136 std::vector<int> indexes;
137 std::string name = tokenizer[i];
138 getIndexes(name, indexes);
139
140 DynamicAny result = currentObject->get(name);
141
142 if ( result.isEmpty() ) // Not found
143 {
144 if ( indexes.empty() ) // We want an object, create it
145 {
146 JSON::Object::Ptr newObject = new JSON::Object();
147 currentObject->set(name, newObject);
148 currentObject = newObject;
149 }
150 else // We need an array
151 {
152 JSON::Array::Ptr newArray;
153 JSON::Array::Ptr parentArray;
154 JSON::Array::Ptr topArray;
155 for(std::vector<int>::iterator it = indexes.begin(); it != indexes.end(); ++it)
156 {
157 newArray = new JSON::Array();
158 if ( topArray.isNull() )
159 {
160 topArray = newArray;
161 }
162
163 if ( ! parentArray.isNull() )
164 {
165 parentArray->add(newArray);
166 }
167
168 for(int i = 0; i <= *it - 1; ++i)
169 {
170 Poco::DynamicAny nullValue;
171 newArray->add(nullValue);
172 }
173
174 parentArray = newArray;
175 }
176
177 currentObject->set(name, topArray);
178 currentObject = new JSON::Object();
179 newArray->add(currentObject);
180 }
181 }
182 else // We have a value
183 {
184 if ( indexes.empty() ) // We want an object

Callers

nothing calls this directly

Calls 12

countMethod · 0.45
getMethod · 0.45
isEmptyMethod · 0.45
emptyMethod · 0.45
setMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
isNullMethod · 0.45
addMethod · 0.45
typeMethod · 0.45
getArrayMethod · 0.45
rbeginMethod · 0.45

Tested by

no test coverage detected