Mercurial > hg > orthanc
comparison OrthancServer/DatabaseWrapper.cpp @ 1241:90d2f320862d
refactoring
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 05 Dec 2014 17:22:53 +0100 |
parents | 62c35e4b67db |
children | 58e6a89c3ef4 |
comparison
equal
deleted
inserted
replaced
1240:62c35e4b67db | 1241:90d2f320862d |
---|---|
334 s.BindInt64(0, parent); | 334 s.BindInt64(0, parent); |
335 s.BindInt64(1, child); | 335 s.BindInt64(1, child); |
336 s.Run(); | 336 s.Run(); |
337 } | 337 } |
338 | 338 |
339 void DatabaseWrapper::GetChildren(Json::Value& childrenPublicIds, | 339 |
340 void DatabaseWrapper::GetChildren(std::list<std::string>& childrenPublicIds, | |
340 int64_t id) | 341 int64_t id) |
341 { | 342 { |
342 SQLite::Statement s(db_, SQLITE_FROM_HERE, "SELECT publicId FROM Resources WHERE parentId=?"); | 343 SQLite::Statement s(db_, SQLITE_FROM_HERE, "SELECT publicId FROM Resources WHERE parentId=?"); |
343 s.BindInt64(0, id); | 344 s.BindInt64(0, id); |
344 | 345 |
345 childrenPublicIds = Json::arrayValue; | 346 childrenPublicIds.clear(); |
346 while (s.Step()) | 347 while (s.Step()) |
347 { | 348 { |
348 childrenPublicIds.append(s.ColumnString(0)); | 349 childrenPublicIds.push_back(s.ColumnString(0)); |
349 } | 350 } |
350 } | 351 } |
351 | 352 |
352 | 353 |
353 void DatabaseWrapper::DeleteResource(int64_t id) | 354 void DatabaseWrapper::DeleteResource(int64_t id) |
786 SQLite::Statement s(db_, SQLITE_FROM_HERE, "SELECT SUM(uncompressedSize) FROM AttachedFiles"); | 787 SQLite::Statement s(db_, SQLITE_FROM_HERE, "SELECT SUM(uncompressedSize) FROM AttachedFiles"); |
787 s.Run(); | 788 s.Run(); |
788 return static_cast<uint64_t>(s.ColumnInt64(0)); | 789 return static_cast<uint64_t>(s.ColumnInt64(0)); |
789 } | 790 } |
790 | 791 |
791 void DatabaseWrapper::GetAllPublicIds(Json::Value& target, | 792 void DatabaseWrapper::GetAllPublicIds(std::list<std::string>& target, |
792 ResourceType resourceType) | 793 ResourceType resourceType) |
793 { | 794 { |
794 SQLite::Statement s(db_, SQLITE_FROM_HERE, "SELECT publicId FROM Resources WHERE resourceType=?"); | 795 SQLite::Statement s(db_, SQLITE_FROM_HERE, "SELECT publicId FROM Resources WHERE resourceType=?"); |
795 s.BindInt(0, resourceType); | 796 s.BindInt(0, resourceType); |
796 | 797 |
797 target = Json::arrayValue; | 798 target.clear(); |
798 while (s.Step()) | 799 while (s.Step()) |
799 { | 800 { |
800 target.append(s.ColumnString(0)); | 801 target.push_back(s.ColumnString(0)); |
801 } | 802 } |
802 } | 803 } |
803 | 804 |
804 static void UpgradeDatabase(SQLite::Connection& db, | 805 static void UpgradeDatabase(SQLite::Connection& db, |
805 EmbeddedResources::FileResourceId script) | 806 EmbeddedResources::FileResourceId script) |