-
Notifications
You must be signed in to change notification settings - Fork 122
Tp json #6
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
Open
marsault
wants to merge
5
commits into
Laefy:master
Choose a base branch
from
marsault:tp-json
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Tp json #6
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
| .vscode/ | ||
| build/ | ||
| solutions/ | ||
| _build | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| #include "ArrayNode.hpp" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,132 @@ | ||
| #pragma once | ||
|
|
||
| #include "Node.hpp" | ||
|
|
||
| #include <algorithm> | ||
| #include <numeric> | ||
| #include <vector> | ||
|
|
||
| class ArrayNode : public Node | ||
| { | ||
| private: | ||
| std::vector<Node_ptr> _data; | ||
|
|
||
| public: | ||
| std::vector<Node_ptr> const& data() const { return _data; } | ||
|
|
||
| std::string print() const override | ||
| { | ||
| std::string result = "["; | ||
| for (unsigned i = 0; i < _data.size(); ++i) | ||
| { | ||
| if (i > 0) | ||
| result += ","; | ||
| result += _data[i]->print(); | ||
| } | ||
| result += ']'; | ||
| return result; | ||
| } | ||
|
|
||
| void add(Node_ptr node) { _data.push_back(std::move(node)); } | ||
|
|
||
| ArrayNode() | ||
| : Node(NodeKind::ARRAY) | ||
| {} | ||
|
|
||
| ArrayNode(std::vector<Node_ptr> data) | ||
| : Node { NodeKind::ARRAY } | ||
| , _data { std::move(data) } | ||
| {} | ||
|
|
||
| static inline std::unique_ptr<ArrayNode> make_ptr(std::vector<Node_ptr> data = {}) | ||
| { | ||
| return std::make_unique<ArrayNode>(std::move(data)); | ||
| } | ||
|
|
||
| size_t child_count() const override { return _data.size(); } | ||
|
|
||
| ArrayNode* as_ArrayNode() override { return this; } | ||
| const ArrayNode* as_ArrayNode() const override { return this; } | ||
|
|
||
| inline bool operator==(const Node& other) const override | ||
| { | ||
| if (!(other.is_of_kind(kind()))) | ||
| { | ||
| std::cerr << kind() << "!=" << other.kind() << std::endl; | ||
| return false; | ||
| } | ||
| ArrayNode const* other_s = other.as_ArrayNode(); | ||
| size_t size = child_count(); | ||
| if (other_s->child_count() != size) | ||
| { | ||
| std::cerr << size << " != " << other_s->child_count() << std::endl; | ||
| return false; | ||
| } | ||
| for (unsigned i = 0; i < size; i++) | ||
| { | ||
| if (*(other_s->_data[i]) != *(_data[i])) | ||
| { | ||
| std::cerr << *(other_s->_data[i]) << std::endl; | ||
| std::cerr << *_data[i] << std::endl; | ||
| return false; | ||
| } | ||
| } | ||
| return true; | ||
| } | ||
|
|
||
| size_t height() const override | ||
| { | ||
| return std::accumulate(_data.begin(), _data.end(), 0, | ||
| [](size_t i, Node_ptr const& child) | ||
| { return std::max(i, 1u + child->height()); }); | ||
| } | ||
|
|
||
| virtual size_t node_count() const override | ||
| { | ||
| return std::accumulate(_data.begin(), _data.end(), 1, | ||
| [](size_t i, Node_ptr const& child) { return i + child->node_count(); }); | ||
| } | ||
|
|
||
| std::vector<Node_ptr>::iterator begin() { return _data.begin(); } | ||
| std::vector<Node_ptr>::iterator end() { return _data.end(); } | ||
|
|
||
| std::vector<Node_ptr>::const_iterator begin() const { return _data.begin(); } | ||
| std::vector<Node_ptr>::const_iterator end() const { return _data.end(); } | ||
|
|
||
| Node_ptr deep_copy() const override | ||
| { | ||
| auto result = make_ptr(); | ||
| for (auto const& elt : this->data()) | ||
| result->add(elt->deep_copy()); | ||
| return result; | ||
| } | ||
|
|
||
| std::string dot_label() const override { return "[...]"; } | ||
|
|
||
| virtual void dot(std::ostream& o) const | ||
| { | ||
| Node::dot(o); | ||
| o << "subgraph cluster_" << dot_id() << " {style=invis;" << std::endl; | ||
| for (auto it = _data.rbegin(); it != _data.rend(); ++it) | ||
| { | ||
| (*it)->dot(o); | ||
| o << dot_id() << " -> " << (*it)->dot_id() << " ;" << std::endl; | ||
| } | ||
| o << "}" << std::endl; | ||
| } | ||
|
|
||
| Node* at(size_t index) override | ||
| { | ||
| if (index < child_count()) | ||
| return _data.at(index).get(); | ||
| else | ||
| return nullptr; | ||
| } | ||
| const Node* at(size_t index) const override | ||
| { | ||
| if (index < child_count()) | ||
| return _data.at(index).get(); | ||
| else | ||
| return nullptr; | ||
| } | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| #include "BooleanLeaf.hpp" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| #pragma once | ||
|
|
||
| #include "Node.hpp" | ||
|
|
||
| class BooleanLeaf : public Node | ||
| { | ||
| private: | ||
| bool _data; | ||
|
|
||
| public: | ||
| std::string print() const override { return _data ? "true" : "false"; } | ||
| BooleanLeaf(bool data) | ||
| : Node { NodeKind::BOOLEAN } | ||
| , _data { data } | ||
| {} | ||
|
|
||
| static std::unique_ptr<BooleanLeaf> make_ptr(bool data) { return std::make_unique<BooleanLeaf>(data); } | ||
|
|
||
| BooleanLeaf* as_BooleanLeaf() override { return this; } | ||
| BooleanLeaf const* as_BooleanLeaf() const override { return this; } | ||
|
|
||
| inline bool operator==(const Node& other) const override | ||
| { | ||
| if (!(other.is_of_kind(kind()))) | ||
| { | ||
| return false; | ||
| } | ||
| return (_data == other.as_BooleanLeaf()->_data); | ||
| } | ||
|
|
||
| const bool& data() const { return _data; } | ||
|
|
||
| Node_ptr deep_copy() const override { return make_ptr(data()); } | ||
|
|
||
| std::string dot_label() const override { return _data ? "true" : "false"; } | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| file(GLOB TP-JSON-SOURCES *.cpp) | ||
|
|
||
| add_subdirectory(tests) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
j'imagine que c'est la bibliotheque des testes qui veut rajouter '_build' ? Pourrait-on la configurer pour utiliser le 'build' qu'on a déjà (ça me soule un peu d'avoir 2 'build'...) ?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Je ne crois pas, je pense que je faisais des
cmake ..à la main. J'ai supprimé le répertoire et le.gitignorede mon côté.