Definition at line 153 of file main.cpp.
◆ HighScores() [1/3]
| anonymous_namespace{main.cpp}::HighScores::HighScores |
( |
std::filesystem::path | file_path | ) |
|
|
inlineexplicit |
Definition at line 155 of file main.cpp.
155: file_path(std::move(file_path)) { load(); }
◆ HighScores() [2/3]
| anonymous_namespace{main.cpp}::HighScores::HighScores |
( |
std::filesystem::path | file_path | ) |
|
|
inlineexplicit |
Definition at line 104 of file main.cpp.
104: file_path(std::move(file_path)) { load(); }
◆ HighScores() [3/3]
| anonymous_namespace{main.cpp}::HighScores::HighScores |
( |
std::string | filePath | ) |
|
|
inlineexplicit |
Definition at line 155 of file main.cpp.
155: filePath(std::move(filePath)) { read(); }
◆ ~HighScores()
| anonymous_namespace{main.cpp}::HighScores::~HighScores |
( |
| ) |
|
|
inline |
◆ add() [1/2]
| void anonymous_namespace{main.cpp}::HighScores::add |
( |
std::string | name, |
|
|
int | score ) |
|
inline |
Definition at line 157 of file main.cpp.
157 {
158 normalize(name);
159 entries.push_back({std::move(name), score});
160 sortAndTrim();
161 save();
162 }
◆ add() [2/2]
| void anonymous_namespace{main.cpp}::HighScores::add |
( |
std::string | name, |
|
|
int | score ) |
|
inline |
Definition at line 106 of file main.cpp.
106 {
107 normalize(name);
108 entries.push_back({std::move(name), score});
109 sortAndTrim();
110 save();
111 }
◆ addScore()
| void anonymous_namespace{main.cpp}::HighScores::addScore |
( |
const std::string & | name, |
|
|
int | shots ) |
|
inline |
Definition at line 159 of file main.cpp.
159 {
160 entries.push_back({name, shots});
161 sort();
162 if (entries.size() > 10) {
163 entries.resize(10);
164 }
165 }
◆ list() [1/3]
| const std::vector< ScoreEntry > & anonymous_namespace{main.cpp}::HighScores::list |
( |
| ) |
const |
|
inlinenodiscard |
◆ list() [2/3]
| const std::vector< ScoreEntry > & anonymous_namespace{main.cpp}::HighScores::list |
( |
| ) |
const |
|
inlinenodiscard |
◆ list() [3/3]
| const std::vector< Score > & anonymous_namespace{main.cpp}::HighScores::list |
( |
| ) |
const |
|
inlinenodiscard |
◆ qualifies() [1/3]
| bool anonymous_namespace{main.cpp}::HighScores::qualifies |
( |
int | score | ) |
const |
|
inlinenodiscard |
Definition at line 164 of file main.cpp.
164 {
166 return true;
167 }
168 return score > entries.back().score;
169 }
◆ qualifies() [2/3]
| bool anonymous_namespace{main.cpp}::HighScores::qualifies |
( |
int | score | ) |
const |
|
inlinenodiscard |
Definition at line 113 of file main.cpp.
113 {
115 return true;
116 }
117 return score > entries.back().score;
118 }
◆ qualifies() [3/3]
| bool anonymous_namespace{main.cpp}::HighScores::qualifies |
( |
int | shots | ) |
const |
|
inlinenodiscard |
Definition at line 167 of file main.cpp.
167 {
168 if (entries.size() < 10) {
169 return true;
170 }
171 return shots < entries.back().shots;
172 }
◆ write()
| void anonymous_namespace{main.cpp}::HighScores::write |
( |
| ) |
const |
|
inline |
Definition at line 176 of file main.cpp.
176 {
177 std::ofstream out(filePath);
178 if (!out.is_open()) {
179 return;
180 }
181 for (const auto &entry : entries) {
182 out << entry.name << ':' << entry.shots << '\n';
183 }
184 }
The documentation for this class was generated from the following files: