|
10 | 10 | #include "impeller/archivist/archive_class_registration.h"
|
11 | 11 | #include "impeller/archivist/archive_database.h"
|
12 | 12 | #include "impeller/archivist/archive_location.h"
|
13 |
| -#include "impeller/archivist/archive_statement.h" |
14 |
| -#include "impeller/archivist/archive_vector.h" |
15 | 13 |
|
16 | 14 | namespace impeller {
|
17 | 15 |
|
@@ -173,146 +171,4 @@ size_t Archive::UnarchiveInstances(const ArchiveDef& definition,
|
173 | 171 | return itemsRead;
|
174 | 172 | }
|
175 | 173 |
|
176 |
| -ArchiveLocation::ArchiveLocation(Archive& context, |
177 |
| - ArchiveStatement& statement, |
178 |
| - const ArchiveClassRegistration& registration, |
179 |
| - Archivable::ArchiveName name) |
180 |
| - : context_(context), |
181 |
| - statement_(statement), |
182 |
| - registration_(registration), |
183 |
| - name_(name), |
184 |
| - current_class_(registration.GetClassName()) {} |
185 |
| - |
186 |
| -Archivable::ArchiveName ArchiveLocation::GetPrimaryKey() const { |
187 |
| - return name_; |
188 |
| -} |
189 |
| - |
190 |
| -bool ArchiveLocation::Write(ArchiveDef::Member member, |
191 |
| - const std::string& item) { |
192 |
| - auto found = registration_.FindColumn(current_class_, member); |
193 |
| - return found.second ? statement_.WriteValue(found.first, item) : false; |
194 |
| -} |
195 |
| - |
196 |
| -bool ArchiveLocation::WriteIntegral(ArchiveDef::Member member, int64_t item) { |
197 |
| - auto found = registration_.FindColumn(current_class_, member); |
198 |
| - return found.second ? statement_.WriteValue(found.first, item) : false; |
199 |
| -} |
200 |
| - |
201 |
| -bool ArchiveLocation::Write(ArchiveDef::Member member, double item) { |
202 |
| - auto found = registration_.FindColumn(current_class_, member); |
203 |
| - return found.second ? statement_.WriteValue(found.first, item) : false; |
204 |
| -} |
205 |
| - |
206 |
| -bool ArchiveLocation::Write(ArchiveDef::Member member, const Allocation& item) { |
207 |
| - auto found = registration_.FindColumn(current_class_, member); |
208 |
| - return found.second ? statement_.WriteValue(found.first, item) : false; |
209 |
| -} |
210 |
| - |
211 |
| -bool ArchiveLocation::Write(ArchiveDef::Member member, |
212 |
| - const ArchiveDef& otherDef, |
213 |
| - const Archivable& other) { |
214 |
| - auto found = registration_.FindColumn(current_class_, member); |
215 |
| - |
216 |
| - if (!found.second) { |
217 |
| - return false; |
218 |
| - } |
219 |
| - |
220 |
| - /* |
221 |
| - * We need to fully archive the other instance first because it could |
222 |
| - * have a name that is auto assigned. In that case, we cannot ask it before |
223 |
| - * archival (via `other.archiveName()`). |
224 |
| - */ |
225 |
| - int64_t lastInsert = 0; |
226 |
| - if (!context_.ArchiveInstance(otherDef, other, lastInsert)) { |
227 |
| - return false; |
228 |
| - } |
229 |
| - |
230 |
| - /* |
231 |
| - * Bind the name of the serializable |
232 |
| - */ |
233 |
| - if (!statement_.WriteValue(found.first, lastInsert)) { |
234 |
| - return false; |
235 |
| - } |
236 |
| - |
237 |
| - return true; |
238 |
| -} |
239 |
| - |
240 |
| -std::pair<bool, int64_t> ArchiveLocation::WriteVectorKeys( |
241 |
| - std::vector<int64_t>&& members) { |
242 |
| - ArchiveVector vector(std::move(members)); |
243 |
| - int64_t vectorID = 0; |
244 |
| - if (!context_.ArchiveInstance(ArchiveVector::ArchiveDefinition, // |
245 |
| - vector, // |
246 |
| - vectorID)) { |
247 |
| - return {false, 0}; |
248 |
| - } |
249 |
| - return {true, vectorID}; |
250 |
| -} |
251 |
| - |
252 |
| -bool ArchiveLocation::ReadVectorKeys(Archivable::ArchiveName name, |
253 |
| - std::vector<int64_t>& members) { |
254 |
| - ArchiveVector vector; |
255 |
| - |
256 |
| - if (!context_.UnarchiveInstance(ArchiveVector::ArchiveDefinition, name, |
257 |
| - vector)) { |
258 |
| - return false; |
259 |
| - } |
260 |
| - |
261 |
| - const auto& keys = vector.GetKeys(); |
262 |
| - |
263 |
| - std::move(keys.begin(), keys.end(), std::back_inserter(members)); |
264 |
| - |
265 |
| - return true; |
266 |
| -} |
267 |
| - |
268 |
| -bool ArchiveLocation::Read(ArchiveDef::Member member, std::string& item) { |
269 |
| - auto found = registration_.FindColumn(current_class_, member); |
270 |
| - return found.second ? statement_.ReadValue(found.first, item) : false; |
271 |
| -} |
272 |
| - |
273 |
| -bool ArchiveLocation::ReadIntegral(ArchiveDef::Member member, int64_t& item) { |
274 |
| - auto found = registration_.FindColumn(current_class_, member); |
275 |
| - return found.second ? statement_.ReadValue(found.first, item) : false; |
276 |
| -} |
277 |
| - |
278 |
| -bool ArchiveLocation::Read(ArchiveDef::Member member, double& item) { |
279 |
| - auto found = registration_.FindColumn(current_class_, member); |
280 |
| - return found.second ? statement_.ReadValue(found.first, item) : false; |
281 |
| -} |
282 |
| - |
283 |
| -bool ArchiveLocation::Read(ArchiveDef::Member member, Allocation& item) { |
284 |
| - auto found = registration_.FindColumn(current_class_, member); |
285 |
| - return found.second ? statement_.ReadValue(found.first, item) : false; |
286 |
| -} |
287 |
| - |
288 |
| -bool ArchiveLocation::Read(ArchiveDef::Member member, |
289 |
| - const ArchiveDef& otherDef, |
290 |
| - Archivable& other) { |
291 |
| - auto found = registration_.FindColumn(current_class_, member); |
292 |
| - |
293 |
| - /* |
294 |
| - * Make sure a member is present at that column |
295 |
| - */ |
296 |
| - if (!found.second) { |
297 |
| - return false; |
298 |
| - } |
299 |
| - |
300 |
| - /* |
301 |
| - * Try to find the foreign key in the current items row |
302 |
| - */ |
303 |
| - int64_t foreignKey = 0; |
304 |
| - if (!statement_.ReadValue(found.first, foreignKey)) { |
305 |
| - return false; |
306 |
| - } |
307 |
| - |
308 |
| - /* |
309 |
| - * Find the other item and unarchive by this foreign key |
310 |
| - */ |
311 |
| - if (!context_.UnarchiveInstance(otherDef, foreignKey, other)) { |
312 |
| - return false; |
313 |
| - } |
314 |
| - |
315 |
| - return true; |
316 |
| -} |
317 |
| - |
318 | 174 | } // namespace impeller
|
0 commit comments