Entry.swift 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. // Entry.swift
  2. // This file is part of KeePass.
  3. //
  4. // Copyright © 2019 Maxime Epain. All rights reserved.
  5. //
  6. // KeePass is free software: you can redistribute it and/or modify
  7. // it under the terms of the GNU General Public License as published by
  8. // the Free Software Foundation, either version 3 of the License, or
  9. // (at your option) any later version.
  10. //
  11. // KeePass is distributed in the hope that it will be useful,
  12. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. // GNU General Public License for more details.
  15. //
  16. // You should have received a copy of the GNU General Public License
  17. // along with KeePass. If not, see <https://www.gnu.org/licenses/>.
  18. import Foundation
  19. public let EntryFieldTitle = "Title"
  20. public let EntryFieldUserName = "UserName"
  21. public let EntryFieldPassword = "Password"
  22. public let EntryFieldURL = "URL"
  23. public let EntryFieldNotes = "Notes"
  24. public protocol Entry {
  25. associatedtype Fields: RandomAccessCollection where Fields.Element == Field
  26. var fields: Fields { get }
  27. mutating func set(_ field: Fields.Element)
  28. }
  29. extension Entry {
  30. subscript(_ field: String) -> Fields.Element? {
  31. return fields.first(where: { $0.name == field })
  32. }
  33. }