Skip to content

Commit d61854c

Browse files
committed
refactored Query.hpp
1 parent 76ed6f4 commit d61854c

File tree

2 files changed

+29
-36
lines changed

2 files changed

+29
-36
lines changed

cucumber_cpp/library/Query.cpp

Lines changed: 21 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -39,53 +39,46 @@
3939

4040
namespace cucumber_cpp::library
4141
{
42-
Lineage Lineage::operator+(std::shared_ptr<const cucumber::messages::gherkin_document> gherkinDocument) const
42+
Lineage operator+(Lineage lineage, std::shared_ptr<const cucumber::messages::gherkin_document> gherkinDocument)
4343
{
44-
Lineage copy = *this;
45-
copy.gherkinDocument = gherkinDocument;
46-
return copy;
44+
lineage.gherkinDocument = gherkinDocument;
45+
return std::move(lineage);
4746
}
4847

49-
Lineage Lineage::operator+(std::shared_ptr<const cucumber::messages::feature> feature) const
48+
Lineage operator+(Lineage lineage, std::shared_ptr<const cucumber::messages::feature> feature)
5049
{
51-
Lineage copy = *this;
52-
copy.feature = feature;
53-
return copy;
50+
lineage.feature = feature;
51+
return std::move(lineage);
5452
}
5553

56-
Lineage Lineage::operator+(std::shared_ptr<const cucumber::messages::rule> rule) const
54+
Lineage operator+(Lineage lineage, std::shared_ptr<const cucumber::messages::rule> rule)
5755
{
58-
Lineage copy = *this;
59-
copy.rule = rule;
60-
return copy;
56+
lineage.rule = rule;
57+
return std::move(lineage);
6158
}
6259

63-
Lineage Lineage::operator+(std::shared_ptr<const cucumber::messages::scenario> scenario) const
60+
Lineage operator+(Lineage lineage, std::shared_ptr<const cucumber::messages::scenario> scenario)
6461
{
65-
Lineage copy = *this;
66-
copy.scenario = scenario;
67-
return copy;
62+
lineage.scenario = scenario;
63+
return std::move(lineage);
6864
}
6965

70-
Lineage Lineage::operator+(std::shared_ptr<const cucumber::messages::examples> examples) const
66+
Lineage operator+(Lineage lineage, std::shared_ptr<const cucumber::messages::examples> examples)
7167
{
72-
Lineage copy = *this;
73-
copy.examples = examples;
74-
return copy;
68+
lineage.examples = examples;
69+
return std::move(lineage);
7570
}
7671

77-
Lineage Lineage::operator+(std::shared_ptr<const cucumber::messages::table_row> tableRow) const
72+
Lineage operator+(Lineage lineage, std::shared_ptr<const cucumber::messages::table_row> tableRow)
7873
{
79-
Lineage copy = *this;
80-
copy.tableRow = tableRow;
81-
return copy;
74+
lineage.tableRow = tableRow;
75+
return std::move(lineage);
8276
}
8377

84-
Lineage Lineage::operator+(std::uint32_t featureIndex) const
78+
Lineage operator+(Lineage lineage, std::uint32_t featureIndex)
8579
{
86-
Lineage copy = *this;
87-
copy.featureIndex = featureIndex;
88-
return copy;
80+
lineage.featureIndex = featureIndex;
81+
return std::move(lineage);
8982
}
9083

9184
std::string Lineage::GetUniqueFeatureName() const

cucumber_cpp/library/Query.hpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,6 @@ namespace cucumber_cpp::library
4747
{
4848
struct Lineage
4949
{
50-
Lineage operator+(std::shared_ptr<const cucumber::messages::gherkin_document> gherkinDocument) const;
51-
Lineage operator+(std::shared_ptr<const cucumber::messages::feature> feature) const;
52-
Lineage operator+(std::shared_ptr<const cucumber::messages::rule> rule) const;
53-
Lineage operator+(std::shared_ptr<const cucumber::messages::scenario> scenario) const;
54-
Lineage operator+(std::shared_ptr<const cucumber::messages::examples> examples) const;
55-
Lineage operator+(std::shared_ptr<const cucumber::messages::table_row> tableRow) const;
56-
Lineage operator+(std::uint32_t featureIndex) const;
57-
5850
std::string GetUniqueFeatureName() const;
5951
std::string GetScenarioAndOrRuleName() const;
6052

@@ -68,6 +60,14 @@ namespace cucumber_cpp::library
6860
std::uint32_t featureIndex{ 0 };
6961
};
7062

63+
Lineage operator+(Lineage lineage, std::shared_ptr<const cucumber::messages::gherkin_document> gherkinDocument);
64+
Lineage operator+(Lineage lineage, std::shared_ptr<const cucumber::messages::feature> feature);
65+
Lineage operator+(Lineage lineage, std::shared_ptr<const cucumber::messages::rule> rule);
66+
Lineage operator+(Lineage lineage, std::shared_ptr<const cucumber::messages::scenario> scenario);
67+
Lineage operator+(Lineage lineage, std::shared_ptr<const cucumber::messages::examples> examples);
68+
Lineage operator+(Lineage lineage, std::shared_ptr<const cucumber::messages::table_row> tableRow);
69+
Lineage operator+(Lineage lineage, std::uint32_t featureIndex);
70+
7171
struct Query
7272
{
7373
Query& operator+=(const cucumber::messages::envelope& envelope);

0 commit comments

Comments
 (0)