struct PathString
cangjie
public struct PathString <: Equatable<PathString> & Equatable<String> & Hashable & ToString功能:表示请求路径字符串。
提供 Path 和 PathBase 值的正确转义,用于重建请求或重定向 URI。
父类型:
- Equatable<PathString>
Equatable<String>HashableToString
成员概览
| 成员 | 功能 |
|---|---|
| init(String) | 使用未转义路径值创建实例。 |
| let empty | 表示空路径字符串。 |
| prop value | 返回原始路径值。 |
| prop hasValue | 检查当前实例是否包含路径值。 |
| func toString() | 返回当前路径的字符串表示。 |
| func toUriComponent() | 返回 URI 格式的路径字符串。 |
| func fromUriComponent(String) | 从 URI 路径组件创建实例。 |
| func startsWithSegments(PathString) | 按路径段检查当前路径是否以前缀路径开头。 |
| func startsWithSegments(PathString, Bool) | 按路径段检查当前路径是否以前缀路径开头。 |
| func add(PathString) | 拼接两个路径字符串。 |
| func add(QueryString) | 将路径与查询字符串合并为 URI 字符串。 |
| func ==(PathString) | 比较两个路径字符串是否相等。 |
| func ==(String) | 比较当前路径与字符串值是否相等。 |
| func hashCode() | 返回当前路径的哈希值。 |
| func +(PathString) | 使用加号运算符合并两个路径字符串。 |
| func +(QueryString) | 使用加号运算符合并路径和查询字符串。 |
| func +(String) | 使用加号运算符将路径与字符串拼接。 |
init(String)
cangjie
public init(value: String)功能:使用未转义路径值创建实例。
参数:
- value:
String- 未转义的路径值。
异常:
IllegalArgumentException- 当非空路径未以/开头时抛出。
let empty
cangjie
public static let empty: PathString = PathString("")功能:表示空路径字符串。
类型:PathString
prop value
cangjie
public prop value: String功能:返回原始路径值。
类型:String
prop hasValue
cangjie
public prop hasValue: Bool功能:检查当前实例是否包含路径值。
类型:Bool
func toString()
cangjie
public func toString(): String功能:返回当前路径的字符串表示。
返回值:
String- 当前路径的 URI 组件表示。
func toUriComponent()
cangjie
public func toUriComponent(): String功能:返回 URI 格式的路径字符串。
返回值:
String- 按 URI 规则转义后的路径字符串。
func fromUriComponent(String)
cangjie
public static func fromUriComponent(uriComponent: String): PathString功能:从 URI 路径组件创建实例。
参数:
- uriComponent:
String- URI 中的路径组件。
返回值:
- PathString - 创建后的路径字符串实例。
func startsWithSegments(PathString)
cangjie
public func startsWithSegments(that: PathString): ?PathString功能:按路径段检查当前路径是否以前缀路径开头。
参数:
- that: PathString - 要匹配的前缀路径。
返回值:
- ?PathString - 匹配成功时返回剩余路径,否则返回空。
func startsWithSegments(PathString, Bool)
cangjie
public func startsWithSegments(that: PathString, ignoreCase: Bool): ?PathString功能:按路径段检查当前路径是否以前缀路径开头。
参数:
- that: PathString - 要匹配的前缀路径。
- ignoreCase:
Bool- 是否忽略大小写。
返回值:
- ?PathString - 匹配成功时返回剩余路径,否则返回空。
func add(PathString)
cangjie
public func add(other: PathString): PathString功能:拼接两个路径字符串。
参数:
- other: PathString - 要追加的路径字符串。
返回值:
- PathString - 拼接后的路径字符串。
func add(QueryString)
cangjie
public func add(other: QueryString): String功能:将路径与查询字符串合并为 URI 字符串。
参数:
- other: QueryString - 要追加的查询字符串。
返回值:
String- 合并后的 URI 字符串。
func ==(PathString)
cangjie
public operator func ==(other: PathString): Bool功能:比较两个路径字符串是否相等。
参数:
- other: PathString - 要比较的路径字符串。
返回值:
Bool- 如果两个路径字符串相等则返回 true,否则返回 false。
func ==(String)
cangjie
public operator func ==(other: String): Bool功能:比较当前路径与字符串值是否相等。
参数:
- other:
String- 要比较的字符串值。
返回值:
Bool- 如果两者相等则返回 true,否则返回 false。
func hashCode()
cangjie
public func hashCode(): Int64功能:返回当前路径的哈希值。
返回值:
Int64- 当前路径的哈希值。
func +(PathString)
cangjie
public operator func +(other: PathString): PathString功能:使用加号运算符合并两个路径字符串。
参数:
- other: PathString - 要追加的路径字符串。
返回值:
- PathString - 合并后的路径字符串。
func +(QueryString)
cangjie
public operator func +(other: QueryString): String功能:使用加号运算符合并路径和查询字符串。
参数:
- other: QueryString - 要追加的查询字符串。
返回值:
String- 合并后的 URI 字符串。
func +(String)
cangjie
public operator func +(other: String): String功能:使用加号运算符将路径与字符串拼接。
参数:
- other:
String- 要追加的字符串。
返回值:
String- 拼接后的字符串结果。