Skip to content

Commit

Permalink
Added protocol extension method
Browse files Browse the repository at this point in the history
  • Loading branch information
davidask committed May 12, 2016
1 parent 5599c61 commit b914116
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .swift-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
swift-DEVELOPMENT-SNAPSHOT-2016-04-12-a
DEVELOPMENT-SNAPSHOT-2016-05-03-a
6 changes: 3 additions & 3 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import PackageDescription
let package = Package(
name: "SQL",
dependencies: [
.Package(url: "https://github.com/Zewo/String.git", majorVersion: 0, minor: 5),
.Package(url: "https://github.com/Zewo/URI.git", majorVersion: 0, minor: 5),
.Package(url: "https://github.com/Zewo/Log.git", majorVersion: 0, minor: 5)
.Package(url: "https://github.com/Zewo/String.git", majorVersion: 0, minor: 7),
.Package(url: "https://github.com/Zewo/URI.git", majorVersion: 0, minor: 7),
.Package(url: "https://github.com/Zewo/Log.git", majorVersion: 0, minor: 6)
]
)
21 changes: 6 additions & 15 deletions Sources/SQL/Core/ConnectionProtocol.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,12 @@
@_exported import URI
@_exported import Log

public protocol ConnectionInfoProtocol: StringLiteralConvertible {

/**
* ConnectionInfoProtocol is an adapter-specific protocol that holds necessary
* values to connect to a database. Associated with `ConnectionProtocol.ConnectionInfo`
*/
public protocol ConnectionInfoProtocol {
var host: String { get }
var port: Int { get }
var databaseName: String { get }
Expand All @@ -35,20 +40,6 @@ public protocol ConnectionInfoProtocol: StringLiteralConvertible {
init(_ uri: URI) throws
}

public extension ConnectionInfoProtocol {
public init(stringLiteral value: String) {
try! self.init(URI(value))
}

public init(unicodeScalarLiteral value: String) {
self.init(stringLiteral: value)
}

public init(extendedGraphemeClusterLiteral value: String) {
self.init(stringLiteral: value)
}
}

public protocol ConnectionProtocol: class {
associatedtype InternalStatus
associatedtype Result: ResultProtocol
Expand Down
4 changes: 4 additions & 0 deletions Sources/SQL/Core/ResultProtocol.swift
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,8 @@ extension ResultProtocol {
public var endIndex: Int {
return count
}

public func index(after: Int) -> Int {
return after + 1
}
}
3 changes: 2 additions & 1 deletion Sources/SQL/Model/Model.swift
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ public extension Collection where Iterator.Element == (DeclaredField, Optional<S
public func queryComponentsForValuePlaceHolders(isolated isolate: Bool) -> QueryComponents {
var strings = [String]()

for _ in startIndex..<endIndex {

indices.forEach { _ in

This comment has been minimized.

Copy link
@antonmes

antonmes May 12, 2016

Contributor

this could be for _ in self witch is faster than forEach

This comment has been minimized.

Copy link
@davidask

davidask May 12, 2016

Author Contributor

Updating this for patch.

strings.append(QueryComponents.valuePlaceholder)
}

Expand Down

0 comments on commit b914116

Please sign in to comment.