Mercurial > hg > orthanc
comparison OrthancServer/DatabaseWrapper.cpp @ 1301:5d56cfa49f68
rename
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 09 Feb 2015 15:31:29 +0100 |
parents | 919dfb2fb3fe |
children | 5fe254fb1c93 |
comparison
equal
deleted
inserted
replaced
1300:919dfb2fb3fe | 1301:5d56cfa49f68 |
---|---|
421 s.Run(); | 421 s.Run(); |
422 } | 422 } |
423 | 423 |
424 | 424 |
425 | 425 |
426 void DatabaseWrapper::ListAvailableAttachments(std::list<FileContentType>& result, | 426 void DatabaseWrapper::ListAvailableAttachments(std::list<FileContentType>& target, |
427 int64_t id) | 427 int64_t id) |
428 { | 428 { |
429 result.clear(); | 429 target.clear(); |
430 | 430 |
431 SQLite::Statement s(db_, SQLITE_FROM_HERE, | 431 SQLite::Statement s(db_, SQLITE_FROM_HERE, |
432 "SELECT fileType FROM AttachedFiles WHERE id=?"); | 432 "SELECT fileType FROM AttachedFiles WHERE id=?"); |
433 s.BindInt64(0, id); | 433 s.BindInt64(0, id); |
434 | 434 |
435 while (s.Step()) | 435 while (s.Step()) |
436 { | 436 { |
437 result.push_back(static_cast<FileContentType>(s.ColumnInt(0))); | 437 target.push_back(static_cast<FileContentType>(s.ColumnInt(0))); |
438 } | 438 } |
439 } | 439 } |
440 | 440 |
441 bool DatabaseWrapper::LookupAttachment(FileInfo& attachment, | 441 bool DatabaseWrapper::LookupAttachment(FileInfo& attachment, |
442 int64_t id, | 442 int64_t id, |
517 s2.ColumnString(3)); | 517 s2.ColumnString(3)); |
518 } | 518 } |
519 } | 519 } |
520 | 520 |
521 | 521 |
522 bool DatabaseWrapper::GetParentPublicId(std::string& result, | 522 bool DatabaseWrapper::GetParentPublicId(std::string& target, |
523 int64_t id) | 523 int64_t id) |
524 { | 524 { |
525 SQLite::Statement s(db_, SQLITE_FROM_HERE, "SELECT a.publicId FROM Resources AS a, Resources AS b " | 525 SQLite::Statement s(db_, SQLITE_FROM_HERE, "SELECT a.publicId FROM Resources AS a, Resources AS b " |
526 "WHERE a.internalId = b.parentId AND b.internalId = ?"); | 526 "WHERE a.internalId = b.parentId AND b.internalId = ?"); |
527 s.BindInt64(0, id); | 527 s.BindInt64(0, id); |
528 | 528 |
529 if (s.Step()) | 529 if (s.Step()) |
530 { | 530 { |
531 result = s.ColumnString(0); | 531 target = s.ColumnString(0); |
532 return true; | 532 return true; |
533 } | 533 } |
534 else | 534 else |
535 { | 535 { |
536 return false; | 536 return false; |
537 } | 537 } |
538 } | 538 } |
539 | 539 |
540 | 540 |
541 void DatabaseWrapper::GetChildrenPublicId(std::list<std::string>& result, | 541 void DatabaseWrapper::GetChildrenPublicId(std::list<std::string>& target, |
542 int64_t id) | 542 int64_t id) |
543 { | 543 { |
544 SQLite::Statement s(db_, SQLITE_FROM_HERE, "SELECT a.publicId FROM Resources AS a, Resources AS b " | 544 SQLite::Statement s(db_, SQLITE_FROM_HERE, "SELECT a.publicId FROM Resources AS a, Resources AS b " |
545 "WHERE a.parentId = b.internalId AND b.internalId = ?"); | 545 "WHERE a.parentId = b.internalId AND b.internalId = ?"); |
546 s.BindInt64(0, id); | 546 s.BindInt64(0, id); |
547 | 547 |
548 result.clear(); | 548 target.clear(); |
549 | 549 |
550 while (s.Step()) | 550 while (s.Step()) |
551 { | 551 { |
552 result.push_back(s.ColumnString(0)); | 552 target.push_back(s.ColumnString(0)); |
553 } | 553 } |
554 } | 554 } |
555 | 555 |
556 | 556 |
557 void DatabaseWrapper::GetChildrenInternalId(std::list<int64_t>& result, | 557 void DatabaseWrapper::GetChildrenInternalId(std::list<int64_t>& target, |
558 int64_t id) | 558 int64_t id) |
559 { | 559 { |
560 SQLite::Statement s(db_, SQLITE_FROM_HERE, "SELECT a.internalId FROM Resources AS a, Resources AS b " | 560 SQLite::Statement s(db_, SQLITE_FROM_HERE, "SELECT a.internalId FROM Resources AS a, Resources AS b " |
561 "WHERE a.parentId = b.internalId AND b.internalId = ?"); | 561 "WHERE a.parentId = b.internalId AND b.internalId = ?"); |
562 s.BindInt64(0, id); | 562 s.BindInt64(0, id); |
563 | 563 |
564 result.clear(); | 564 target.clear(); |
565 | 565 |
566 while (s.Step()) | 566 while (s.Step()) |
567 { | 567 { |
568 result.push_back(s.ColumnInt64(0)); | 568 target.push_back(s.ColumnInt64(0)); |
569 } | 569 } |
570 } | 570 } |
571 | 571 |
572 | 572 |
573 void DatabaseWrapper::LogChange(int64_t internalId, | 573 void DatabaseWrapper::LogChange(int64_t internalId, |
942 s.BindInt64(0, internalId); | 942 s.BindInt64(0, internalId); |
943 return s.Step(); | 943 return s.Step(); |
944 } | 944 } |
945 | 945 |
946 | 946 |
947 void DatabaseWrapper::LookupIdentifier(std::list<int64_t>& result, | 947 void DatabaseWrapper::LookupIdentifier(std::list<int64_t>& target, |
948 const DicomTag& tag, | 948 const DicomTag& tag, |
949 const std::string& value) | 949 const std::string& value) |
950 { | 950 { |
951 if (!tag.IsIdentifier()) | 951 if (!tag.IsIdentifier()) |
952 { | 952 { |
958 | 958 |
959 s.BindInt(0, tag.GetGroup()); | 959 s.BindInt(0, tag.GetGroup()); |
960 s.BindInt(1, tag.GetElement()); | 960 s.BindInt(1, tag.GetElement()); |
961 s.BindString(2, value); | 961 s.BindString(2, value); |
962 | 962 |
963 result.clear(); | 963 target.clear(); |
964 | 964 |
965 while (s.Step()) | 965 while (s.Step()) |
966 { | 966 { |
967 result.push_back(s.ColumnInt64(0)); | 967 target.push_back(s.ColumnInt64(0)); |
968 } | 968 } |
969 } | 969 } |
970 | 970 |
971 | 971 |
972 void DatabaseWrapper::LookupIdentifier(std::list<int64_t>& result, | 972 void DatabaseWrapper::LookupIdentifier(std::list<int64_t>& target, |
973 const std::string& value) | 973 const std::string& value) |
974 { | 974 { |
975 SQLite::Statement s(db_, SQLITE_FROM_HERE, | 975 SQLite::Statement s(db_, SQLITE_FROM_HERE, |
976 "SELECT id FROM DicomIdentifiers WHERE value=?"); | 976 "SELECT id FROM DicomIdentifiers WHERE value=?"); |
977 | 977 |
978 s.BindString(0, value); | 978 s.BindString(0, value); |
979 | 979 |
980 result.clear(); | 980 target.clear(); |
981 | 981 |
982 while (s.Step()) | 982 while (s.Step()) |
983 { | 983 { |
984 result.push_back(s.ColumnInt64(0)); | 984 target.push_back(s.ColumnInt64(0)); |
985 } | 985 } |
986 } | 986 } |
987 | 987 |
988 | 988 |
989 void DatabaseWrapper::GetAllMetadata(std::map<MetadataType, std::string>& result, | 989 void DatabaseWrapper::GetAllMetadata(std::map<MetadataType, std::string>& target, |
990 int64_t id) | 990 int64_t id) |
991 { | 991 { |
992 result.clear(); | 992 target.clear(); |
993 | 993 |
994 SQLite::Statement s(db_, SQLITE_FROM_HERE, "SELECT type, value FROM Metadata WHERE id=?"); | 994 SQLite::Statement s(db_, SQLITE_FROM_HERE, "SELECT type, value FROM Metadata WHERE id=?"); |
995 s.BindInt64(0, id); | 995 s.BindInt64(0, id); |
996 | 996 |
997 while (s.Step()) | 997 while (s.Step()) |
998 { | 998 { |
999 MetadataType key = static_cast<MetadataType>(s.ColumnInt(0)); | 999 MetadataType key = static_cast<MetadataType>(s.ColumnInt(0)); |
1000 result[key] = s.ColumnString(1); | 1000 target[key] = s.ColumnString(1); |
1001 } | 1001 } |
1002 } | 1002 } |
1003 | 1003 |
1004 } | 1004 } |