Giter Club home page Giter Club logo

potentcodables's People

Contributors

cabo avatar kdubb avatar rockyyara avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

potentcodables's Issues

Windows Support

I just deleted / commented out all the YAML stuff and all the tests pass on Windows. I only need CBOR support, and was wondering whether you'd consider breaking PotentCodables into separate packages?
Because Cfyaml uses autoconf, I anticipate difficulty porting it to Windows, but it's possible it could work if I can find a replacement unistd.h. But all of those are long-term solutions. I'd rather not fork your library, but it seems to be the only actively-maintained implementation of CBOR coding anywhere.

Although, now that I look at your docs, I'm not sure whether you actually supply the functionality I need. I want to accomplish essentially this (that package also has portability problems and is not currently passing its own tests).

Does PotentCodables do that? What I see in the docs (though I may have missed it) looks like it's for dynamically traversing already-serialized CBOR representations, but I have an existing Codable data structure that I want to serialize and deserialize.

Thanks!

Trouble with Encoding of Versioning

Hi,

I'm having some issues with the versioning scheme. How can I encode the following structure in asn1: Version ::= INTEGER { v1(1) }, in other words, how should structure and scheme look like?

Thanks for your help in advance,
Nico

ASN.1 GeneralizedTime parsing fails if there's no optional millisecond part

image

My solution which solves the issue:

PotentCodables/Sources/PotentASN1/ASN1Reader.swift

    case .generalizedTime:
      let string = try parseString(&itemBuffer, tag: tag, encoding: .ascii)
      
      let dateFormatter: DateFormatter
      
      if string.contains(".") {
        dateFormatter = generalizedFormatter
      } else {
        dateFormatter = generalizedFormatterWithoutMillis
      }

      return .generalizedTime(dateFormatter.date(from: string)!)

private let generalizedFormatterWithoutMillis: DateFormatter = {
  let formatter = DateFormatter()
  formatter.calendar = Calendar(identifier: .iso8601)
  formatter.locale = Locale(identifier: "en_US_POSIX")
  formatter.timeZone = TimeZone(secondsFromGMT: 0)
  formatter.dateFormat = "yyyyMMddHHmmssXXXXX"
  return formatter
}()

I can push and make a PR if it's OK.

AnyValue dictionary encoding as an Array

Hey!

I'm seeing a weird bug where a dictionary is getting encoded as an array? This didn't used to happen in older version (I tried on v1.8.2)

Example code to reproduce the issue:

import Foundation
import PotentCodables


func main() {
	
	var myDict = [String: [String: AnyValue]]()
	
	myDict["key"] = ["innerVal": AnyValue.bool(true)]
	myDict["key2"] = ["innerDict": AnyValue.dictionary([
		"innerKey": true
	])]
							 
	let encoder = JSONEncoder()
	encoder.outputFormatting = .prettyPrinted
	
	if let data = try? encoder.encode(myDict), let json = String.init(data: data, encoding: .utf8) {
		print(json)
	}
	
}

main()

Output on current main:

{
  "key" : {
    "innerVal" : true
  },
  "key2" : {
    "innerDict" : [
      "innerKey",
      true
    ]
  }
}

Output on 1.8.2:

{
  "key" : {
    "innerVal" : true
  },
  "key2" : {
    "innerDict" : {
      "innerKey" : true
    }
  }
}

Cannot build in latest Xcode 13

It seems like the BidirectionalCollection and Collection protocols has changed.

/Users/johansellstrom/PotentCodables/Sources/PotentASN1/AnyString.swift:62:1: error: type 'AnyString' does not conform to protocol 'BidirectionalCollection'
extension AnyString: StringProtocol {
^
/Users/johansellstrom/PotentCodables/Sources/PotentASN1/AnyString.swift:62:1: error: unavailable subscript 'subscript(:)' was used to satisfy a requirement of protocol 'BidirectionalCollection'
extension AnyString: StringProtocol {
^
Swift.Collection:3:12: note: 'subscript(
:)' declared here
public subscript(bounds: Range<Self.Index>) -> Self.SubSequence { get }
^
Swift.BidirectionalCollection:14:14: note: requirement 'subscript(:)' declared here
override subscript(bounds: Range<Self.Index>) -> Self.SubSequence { get }
^
/Users/johansellstrom/PotentCodables/Sources/PotentASN1/AnyString.swift:62:1: error: type 'AnyString' does not conform to protocol 'Collection'
extension AnyString: StringProtocol {
^
/Users/johansellstrom/PotentCodables/Sources/PotentASN1/AnyString.swift:62:1: error: unavailable subscript 'subscript(
:)' was used to satisfy a requirement of protocol 'Collection'
extension AnyString: StringProtocol {
^
Swift.Collection:3:12: note: 'subscript(:)' declared here
public subscript(bounds: Range<Self.Index>) -> Self.SubSequence { get }
^
Swift.Collection:12:5: note: requirement 'subscript(
:)' declared here
subscript(bounds: Range<Self.Index>) -> Self.SubSequence { get }
^

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.