RSDAnswerResultType

public struct RSDAnswerResultType : Codable, Hashable, Equatable

RSDAnswerResultType is a Codable struct that can be used to describe how to encode and decode an RSDAnswerResult. It carries information about the type of the value and how to encode it. This struct serves a different purpose from the RSDFormDataType because it only carries information required to store a result and not additional information about presentation style.

  • Override equality to not include the original formDataType.

    Declaration

    Swift

    public static func == (lhs: RSDAnswerResultType, rhs: RSDAnswerResultType) -> Bool
  • Override the hash into to not include the original formDataType.

    Declaration

    Swift

    public func hash(into hasher: inout Hasher)
  • The base type of the answer result. This is used to indicate what the type is of the value being stored. The value stored in the RSDAnswerResult should be convertable to one of these base types.

    See more

    Declaration

    Swift

    public enum BaseType : String, Codable, RSDStringEnumSet
  • The sequence type of the answer result. This is used to represent a multiple-choice answer array or a key/value dictionary.

    See more

    Declaration

    Swift

    public enum SequenceType : String, Codable, RSDStringEnumSet
  • The base type for the answer.

    Declaration

    Swift

    public let baseType: BaseType
  • The sequence type (if any) for the answer.

    Declaration

    Swift

    public let sequenceType: SequenceType?
  • The original data type of the form input item.

    Declaration

    Swift

    public var formDataType: RSDFormDataType?
  • The date format that should be used to encode and decode the answer.

    Declaration

    Swift

    public let dateFormat: String?
  • The date formatter locale identifier that should be used to encode and decode the answer. If nil, the default Locale will be set to en_US_POSIX.

    Declaration

    Swift

    public var dateLocaleIdentifier: String?
  • The unit (if any) to store with the answer for localized measurement conversion.

    Declaration

    Swift

    public let unit: String?
  • A conveniece property for accessing the formatter used to encode and decode a date.

    Declaration

    Swift

    public var dateFormatter: DateFormatter? { get }
  • The sequence separator to use when storing a multiple component answer as a string.

    For example, blood pressure might be represented using an array with two fields but is stored as a single string value of 120/90. In this case, / would be the separator.

    Declaration

    Swift

    public private(set) var sequenceSeparator: String? {
      get
      }
  • The initializer for the RSDAnswerResultType.

    Declaration

    Swift

    public init(baseType: BaseType, sequenceType: SequenceType? = nil, formDataType: RSDFormDataType? = nil, dateFormat: String? = nil, unit: String? = nil, sequenceSeparator: String? = nil)

    Parameters

    baseType

    The base type for the answer. Required.

    sequenceType

    The sequence type (if any) for the answer. Default is nil.

    dateFormat

    The date format that should be used to encode the answer. Default is nil.

    unit

    The unit (if any) to store with the answer for localized measurement conversion. Default is nil.

    sequenceSeparator

    The sequence separator to use when storing a multiple component answer as a string. Default is nil.

  • Static type for a RSDAnswerResultType with a Bool base type.

    Declaration

    Swift

    public static let boolean: RSDAnswerResultType
  • Static type for a RSDAnswerResultType with a Data base type.

    Declaration

    Swift

    public static let data: RSDAnswerResultType
  • Static type for a RSDAnswerResultType with a Date base type.

    Declaration

    Swift

    public static let date: RSDAnswerResultType
  • Static type for a RSDAnswerResultType with a Double or Decimal base type.

    Declaration

    Swift

    public static let decimal: RSDAnswerResultType
  • Static type for a RSDAnswerResultType with an Int base type.

    Declaration

    Swift

    public static let integer: RSDAnswerResultType
  • Static type for a RSDAnswerResultType with a String base type.

    Declaration

    Swift

    public static let string: RSDAnswerResultType
  • Static type for a RSDAnswerResultType with a Codable base type.

    Declaration

    Swift

    public static let codable: RSDAnswerResultType
  • Decode a RSDJSONValue from the given JSON value.

    Throws

    DecodingError if the encountered stored value cannot be decoded.

    Declaration

    Swift

    public func jsonDecode(from jsonValue: RSDJSONSerializable?, with dataType: RSDFormDataType? = nil) throws -> Any?

    Parameters

    jsonValue

    The JSON value (from an array or dictionary) with the answer.

    dataType

    The data type to use to hint at the transform.

    Return Value

    The decoded value or nil if the value is not present.

  • Decode a RSDJSONValue from the given decoder.

    Throws

    DecodingError if the encountered stored value cannot be decoded.

    Declaration

    Swift

    public func decodeValue(from decoder: Decoder) throws -> RSDJSONValue?

    Parameters

    decoder

    The decoder that holds the value.

    Return Value

    The decoded value or nil if the value is not present.

  • Returns a JSON serializable object that is encoded for this answer type from the given value.

    • paramenter value: The value to encode.

    Declaration

    Swift

    public func jsonEncode(from value: Any?) throws -> RSDJSONSerializable?

    Return Value

    The JSON serializable object for this encodable.

  • Encode a value to the given encoder.

    Throws

    EncodingError if the value cannot be encoded.

    Declaration

    Swift

    public func encode(_ value: Any?, to encoder: Encoder) throws

    Parameters

    value

    The value to encode.

    encoder

    The encoder to mutate.