Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create a MusicXMLDecoder: XMLDecoder subclass #179

Open
jsbean opened this issue Oct 16, 2019 · 2 comments
Open

Create a MusicXMLDecoder: XMLDecoder subclass #179

jsbean opened this issue Oct 16, 2019 · 2 comments
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed

Comments

@jsbean
Copy link
Member

jsbean commented Oct 16, 2019

Now that we are disabling .trimValueWhitespaces from our decoder, it may make sense to create an XMLDecoder subclass MusicXMLDecoder.

This way we can use MusicXMLDecoder when testing atomic units, so we know we are working with the same thing when decoding a whole MusicXML object.

This will also allow us to wipe XMLCoder from testing, which has seemed slightly out of place.

@jsbean
Copy link
Member Author

jsbean commented Oct 16, 2019

(This could also be made symmetrical as MusicXMLEncoder.)

@jsbean
Copy link
Member Author

jsbean commented Oct 16, 2019

We could also tighten up the API a little, because we know we are always dealing with .utf8:

extension MusicXMLDecoder {
    func decode <T> (_ type: T.Type, from string: String) throws -> T where T: Decodable {
        return try decode(type, string.data(using: utf8)!)
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant