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

Extract the xml parser from carddatabase #3223

Merged
merged 6 commits into from
May 4, 2018

Conversation

ctrlaltca
Copy link
Contributor

Related Ticket(s)

Short roundup of the initial problem

See #3201

What will change with this Pull Request?

The xml parser has been extracted from the card database.
The card database now supports querying multiple parsers; by now the only parser available is the "old" xml file parser.

There should be no user-noticeable difference in card parsing, loading or anything else.

{
public:
virtual ~ICardDatabaseParser() {}
virtual bool getCanParseFile(const QString &name, QIODevice &device) = 0;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

= 0; vs = delete; ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I want a pure virtual function in order to make the class abstract (non-instanceable).
As far as I understand, with = delete the method is not callable, but the class can still be instanced.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://stackoverflow.com/questions/24958270/why-cant-i-declare-a-pure-virtual-function-with-delete Yeah you're right. Didn't realize we could create a fully abstract class in C++ :D

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, in any other language i'd use an interface. In C++ you need some trickery to achieve the same result.

@ZeldaZach
Copy link
Member

You'll want to run the ./clangify.sh file

Copy link
Member

@Daenyth Daenyth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm pretty excited about this. I'd like to explore auto-generating a parser from the XSD at some point down the line to reduce the amount of code we need to maintain

@@ -398,11 +397,11 @@ class CardDatabase : public QObject

LoadStatus loadStatus;

/*
* The available card database parsers
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👎 IMO we should avoid "what is this code" style comments unless it's very hard. In this case naming the variable availableParsers would be enough.

public:
CockatriceXml3Parser() {};
~CockatriceXml3Parser() {};
CockatriceXml3Parser(){};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

=default; ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yay!

Copy link
Member

@ZeldaZach ZeldaZach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works leaving no changes to the files (Besides ordering, which is variable with XML anyway)

@ZeldaZach ZeldaZach merged commit a7f4aac into Cockatrice:master May 4, 2018
@ctrlaltca ctrlaltca deleted the carddb branch May 4, 2018 09:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants