Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cc557fa
commit 131a34d
Showing
8 changed files
with
186 additions
and
78 deletions.
There are no files selected for viewing
This file contains 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 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 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,65 @@ | ||
/***************************************************************************** | ||
* Copyright (c) 2014-2021 OpenRCT2 developers | ||
* | ||
* For a complete list of all authors, please refer to contributors.md | ||
* Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2 | ||
* | ||
* OpenRCT2 is licensed under the GNU General Public License version 3. | ||
*****************************************************************************/ | ||
|
||
#pragma once | ||
|
||
#include <string> | ||
#include <string_view> | ||
#include <vector> | ||
|
||
using ObjectEntryIndex = uint16_t; | ||
|
||
namespace RCT12 | ||
{ | ||
class EntryList | ||
{ | ||
private: | ||
std::vector<std::string> _entries; | ||
|
||
public: | ||
size_t GetCount() const | ||
{ | ||
return _entries.size(); | ||
} | ||
|
||
const std::vector<std::string>& GetEntries() const | ||
{ | ||
return _entries; | ||
} | ||
|
||
ObjectEntryIndex GetOrAddEntry(std::string_view identifier) | ||
{ | ||
for (size_t i = 0; i < _entries.size(); i++) | ||
{ | ||
if (_entries[i] == identifier) | ||
{ | ||
return static_cast<ObjectEntryIndex>(i); | ||
} | ||
} | ||
_entries.emplace_back(identifier); | ||
return static_cast<ObjectEntryIndex>(_entries.size() - 1); | ||
} | ||
|
||
void AddRange(const std::initializer_list<std::string_view> initializerList) | ||
{ | ||
for (auto entry : initializerList) | ||
{ | ||
GetOrAddEntry(entry); | ||
} | ||
} | ||
|
||
template<uint32_t i> void AddRange(const std::string_view (&list)[i]) | ||
{ | ||
for (auto entry : list) | ||
{ | ||
GetOrAddEntry(entry); | ||
} | ||
} | ||
}; | ||
} // namespace RCT12 |
This file contains 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 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 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 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 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