diff options
author | Hop311 <hop3114@gmail.com> | 2023-09-28 22:03:14 +0200 |
---|---|---|
committer | Hop311 <hop3114@gmail.com> | 2023-09-28 22:03:14 +0200 |
commit | 84b5ee7a7749e2dbfeb214b4cedd16d5522f4197 (patch) | |
tree | cd810aceed54196aa62aa766f79039cd57a1e600 | |
parent | 5764126f4a3940320990a9bc3007ba22e89a514c (diff) |
Removed unnecessary `const std::string_view`s
36 files changed, 141 insertions, 141 deletions
diff --git a/src/openvic-simulation/GameManager.cpp b/src/openvic-simulation/GameManager.cpp index 958049d..b0bb0a3 100644 --- a/src/openvic-simulation/GameManager.cpp +++ b/src/openvic-simulation/GameManager.cpp @@ -122,7 +122,7 @@ Date const& GameManager::get_today() const { return today; } -bool GameManager::expand_building(Province::index_t province_index, const std::string_view building_type_identifier) { +bool GameManager::expand_building(Province::index_t province_index, std::string_view building_type_identifier) { set_needs_update(); Province* province = map.get_province_by_index(province_index); if (province == nullptr) { diff --git a/src/openvic-simulation/GameManager.hpp b/src/openvic-simulation/GameManager.hpp index d3f5656..2494dd8 100644 --- a/src/openvic-simulation/GameManager.hpp +++ b/src/openvic-simulation/GameManager.hpp @@ -63,7 +63,7 @@ namespace OpenVic { bool setup(); Date const& get_today() const; - bool expand_building(Province::index_t province_index, const std::string_view building_type_identifier); + bool expand_building(Province::index_t province_index, std::string_view building_type_identifier); /* Hardcoded data for defining things for which parsing from files has * not been implemented, currently mapmodes and building types. diff --git a/src/openvic-simulation/Modifier.cpp b/src/openvic-simulation/Modifier.cpp index 3ec5474..3acfa56 100644 --- a/src/openvic-simulation/Modifier.cpp +++ b/src/openvic-simulation/Modifier.cpp @@ -3,7 +3,7 @@ using namespace OpenVic; using namespace OpenVic::NodeTools; -ModifierEffect::ModifierEffect(const std::string_view new_identifier, bool new_positive_good) +ModifierEffect::ModifierEffect(std::string_view new_identifier, bool new_positive_good) : HasIdentifier { new_identifier }, positive_good { new_positive_good } {} bool ModifierEffect::get_positive_good() const { @@ -74,7 +74,7 @@ ModifierValue ModifierValue::operator-(ModifierValue const& right) const { return ret -= right; } -Modifier::Modifier(const std::string_view new_identifier, ModifierValue&& new_values, icon_t new_icon) +Modifier::Modifier(std::string_view new_identifier, ModifierValue&& new_values, icon_t new_icon) : HasIdentifier { new_identifier }, ModifierValue { std::move(new_values) }, icon { new_icon } {} Modifier::icon_t Modifier::get_icon() const { @@ -94,7 +94,7 @@ Date const& ModifierInstance::get_expiry_date() const { ModifierManager::ModifierManager() : modifier_effects { "modifier effects"}, modifiers { "modifiers" } {} -bool ModifierManager::add_modifier_effect(const std::string_view identifier, bool positive_good) { +bool ModifierManager::add_modifier_effect(std::string_view identifier, bool positive_good) { if (identifier.empty()) { Logger::error("Invalid modifier effect identifier - empty!"); return false; @@ -102,7 +102,7 @@ bool ModifierManager::add_modifier_effect(const std::string_view identifier, boo return modifier_effects.add_item({ identifier, positive_good }); } -bool ModifierManager::add_modifier(const std::string_view identifier, ModifierValue&& values, Modifier::icon_t icon) { +bool ModifierManager::add_modifier(std::string_view identifier, ModifierValue&& values, Modifier::icon_t icon) { if (identifier.empty()) { Logger::error("Invalid modifier effect identifier - empty!"); return false; diff --git a/src/openvic-simulation/Modifier.hpp b/src/openvic-simulation/Modifier.hpp index bfd9ca7..f88102b 100644 --- a/src/openvic-simulation/Modifier.hpp +++ b/src/openvic-simulation/Modifier.hpp @@ -16,7 +16,7 @@ namespace OpenVic { // TODO - format/precision, e.g. 80% vs 0.8 vs 0.800, 2 vs 2.0 vs 200% - ModifierEffect(const std::string_view new_identifier, bool new_positive_good); + ModifierEffect(std::string_view new_identifier, bool new_positive_good); public: ModifierEffect(ModifierEffect&&) = default; @@ -65,7 +65,7 @@ namespace OpenVic { /* A modifier can have no icon (zero). */ const icon_t icon; - Modifier(const std::string_view new_identifier, ModifierValue&& new_values, icon_t new_icon); + Modifier(std::string_view new_identifier, ModifierValue&& new_values, icon_t new_icon); public: Modifier(Modifier&&) = default; @@ -97,7 +97,7 @@ namespace OpenVic { template<typename... Args> NodeTools::node_callback_t _expect_modifier_value_and_keys( NodeTools::callback_t<ModifierValue&&> modifier_callback, NodeTools::key_map_t&& key_map, - const std::string_view key, NodeTools::dictionary_entry_t::expected_count_t expected_count, NodeTools::node_callback_t callback, + std::string_view key, NodeTools::dictionary_entry_t::expected_count_t expected_count, NodeTools::node_callback_t callback, Args... args) const { NodeTools::add_key_map_entry(key_map, key, expected_count, callback); return _expect_modifier_value_and_keys(modifier_callback, std::move(key_map), args...); @@ -106,10 +106,10 @@ namespace OpenVic { public: ModifierManager(); - bool add_modifier_effect(const std::string_view identifier, bool province_good); + bool add_modifier_effect(std::string_view identifier, bool province_good); IDENTIFIER_REGISTRY_ACCESSORS(ModifierEffect, modifier_effect) - bool add_modifier(const std::string_view identifier, ModifierValue&& values, Modifier::icon_t icon); + bool add_modifier(std::string_view identifier, ModifierValue&& values, Modifier::icon_t icon); IDENTIFIER_REGISTRY_ACCESSORS(Modifier, modifier) bool setup_modifier_effects(); diff --git a/src/openvic-simulation/dataloader/NodeTools.cpp b/src/openvic-simulation/dataloader/NodeTools.cpp index 1c7ddf0..4deffe1 100644 --- a/src/openvic-simulation/dataloader/NodeTools.cpp +++ b/src/openvic-simulation/dataloader/NodeTools.cpp @@ -242,7 +242,7 @@ node_callback_t NodeTools::expect_dictionary(key_value_callback_t callback) { return expect_dictionary_and_length(default_length_callback, callback); } -void NodeTools::add_key_map_entry(key_map_t& key_map, const std::string_view key, dictionary_entry_t::expected_count_t expected_count, node_callback_t callback) { +void NodeTools::add_key_map_entry(key_map_t& key_map, std::string_view key, dictionary_entry_t::expected_count_t expected_count, node_callback_t callback) { if (key_map.find(key) == key_map.end()) { key_map.emplace(key, dictionary_entry_t { expected_count, callback }); } else { diff --git a/src/openvic-simulation/dataloader/NodeTools.hpp b/src/openvic-simulation/dataloader/NodeTools.hpp index 2dae05c..20c8dbd 100644 --- a/src/openvic-simulation/dataloader/NodeTools.hpp +++ b/src/openvic-simulation/dataloader/NodeTools.hpp @@ -72,7 +72,7 @@ namespace OpenVic { using enum dictionary_entry_t::expected_count_t; using key_map_t = std::map<std::string, dictionary_entry_t, std::less<void>>; - void add_key_map_entry(key_map_t& key_map, const std::string_view key, dictionary_entry_t::expected_count_t expected_count, node_callback_t callback); + void add_key_map_entry(key_map_t& key_map, std::string_view key, dictionary_entry_t::expected_count_t expected_count, node_callback_t callback); key_value_callback_t dictionary_keys_callback(key_map_t& key_map, bool allow_other_keys); bool check_key_map_counts(key_map_t const& key_map); @@ -83,7 +83,7 @@ namespace OpenVic { template<typename... Args> node_callback_t _expect_dictionary_keys_and_length(length_callback_t length_callback, bool allow_other_keys, key_map_t&& key_map, - const std::string_view key, dictionary_entry_t::expected_count_t expected_count, node_callback_t callback, + std::string_view key, dictionary_entry_t::expected_count_t expected_count, node_callback_t callback, Args... args) { add_key_map_entry(key_map, key, expected_count, callback); return _expect_dictionary_keys_and_length(length_callback, allow_other_keys, std::move(key_map), args...); @@ -91,7 +91,7 @@ namespace OpenVic { template<typename... Args> node_callback_t expect_dictionary_keys_and_length(length_callback_t length_callback, - const std::string_view key, dictionary_entry_t::expected_count_t expected_count, node_callback_t callback, + std::string_view key, dictionary_entry_t::expected_count_t expected_count, node_callback_t callback, Args... args) { return _expect_dictionary_keys_and_length(length_callback, false, {}, key, expected_count, callback, args...); } @@ -169,7 +169,7 @@ namespace OpenVic { template<typename T> requires(std::integral<T>) - callback_t<uint64_t> assign_variable_callback_uint(const std::string_view name, T& var) { + callback_t<uint64_t> assign_variable_callback_uint(std::string_view name, T& var) { return [&var, name](uint64_t val) -> bool { if (val <= static_cast<uint64_t>(std::numeric_limits<T>::max())) { var = val; @@ -183,7 +183,7 @@ namespace OpenVic { template<typename T> requires(std::signed_integral<T>) - callback_t<int64_t> assign_variable_callback_int(const std::string_view name, T& var) { + callback_t<int64_t> assign_variable_callback_int(std::string_view name, T& var) { return [&var, name](int64_t val) -> bool { if (static_cast<int64_t>(std::numeric_limits<T>::lowest()) <= val && val <= static_cast<int64_t>(std::numeric_limits<T>::max())) { var = val; diff --git a/src/openvic-simulation/economy/Good.cpp b/src/openvic-simulation/economy/Good.cpp index 8a04e39..0fd4618 100644 --- a/src/openvic-simulation/economy/Good.cpp +++ b/src/openvic-simulation/economy/Good.cpp @@ -5,9 +5,9 @@ using namespace OpenVic; using namespace OpenVic::NodeTools; -GoodCategory::GoodCategory(const std::string_view new_identifier) : HasIdentifier { new_identifier } {} +GoodCategory::GoodCategory(std::string_view new_identifier) : HasIdentifier { new_identifier } {} -Good::Good(const std::string_view new_identifier, colour_t new_colour, GoodCategory const& new_category, price_t new_base_price, +Good::Good(std::string_view new_identifier, colour_t new_colour, GoodCategory const& new_category, price_t new_base_price, bool new_available_from_start, bool new_tradeable, bool new_money, bool new_overseas_penalty) : HasIdentifierAndColour { new_identifier, new_colour, true, false }, category { new_category }, @@ -58,7 +58,7 @@ void Good::reset_to_defaults() { GoodManager::GoodManager() : good_categories { "good categories" }, goods { "goods" } {} -bool GoodManager::add_good_category(const std::string_view identifier) { +bool GoodManager::add_good_category(std::string_view identifier) { if (identifier.empty()) { Logger::error("Invalid good category identifier - empty!"); return false; @@ -66,7 +66,7 @@ bool GoodManager::add_good_category(const std::string_view identifier) { return good_categories.add_item({ identifier }); } -bool GoodManager::add_good(const std::string_view identifier, colour_t colour, GoodCategory const* category, +bool GoodManager::add_good(std::string_view identifier, colour_t colour, GoodCategory const* category, Good::price_t base_price, bool available_from_start, bool tradeable, bool money, bool overseas_penalty) { if (identifier.empty()) { Logger::error("Invalid good identifier - empty!"); diff --git a/src/openvic-simulation/economy/Good.hpp b/src/openvic-simulation/economy/Good.hpp index 792336d..7f020fe 100644 --- a/src/openvic-simulation/economy/Good.hpp +++ b/src/openvic-simulation/economy/Good.hpp @@ -9,7 +9,7 @@ namespace OpenVic { friend struct GoodManager; private: - GoodCategory(const std::string_view new_identifier); + GoodCategory(std::string_view new_identifier); public: GoodCategory(GoodCategory&&) = default; @@ -40,7 +40,7 @@ namespace OpenVic { const bool available_from_start, tradeable, money, overseas_penalty; bool available; - Good(const std::string_view new_identifier, colour_t new_colour, GoodCategory const& new_category, price_t new_base_price, + Good(std::string_view new_identifier, colour_t new_colour, GoodCategory const& new_category, price_t new_base_price, bool new_available_from_start, bool new_tradeable, bool new_money, bool new_overseas_penalty); public: @@ -65,10 +65,10 @@ namespace OpenVic { public: GoodManager(); - bool add_good_category(const std::string_view identifier); + bool add_good_category(std::string_view identifier); IDENTIFIER_REGISTRY_ACCESSORS_CUSTOM_PLURAL(GoodCategory, good_category, good_categories) - bool add_good(const std::string_view identifier, colour_t colour, GoodCategory const* category, Good::price_t base_price, + bool add_good(std::string_view identifier, colour_t colour, GoodCategory const* category, Good::price_t base_price, bool available_from_start, bool tradeable, bool money, bool overseas_penalty); IDENTIFIER_REGISTRY_ACCESSORS(Good, good) diff --git a/src/openvic-simulation/map/Building.cpp b/src/openvic-simulation/map/Building.cpp index 29ee354..4e26ab9 100644 --- a/src/openvic-simulation/map/Building.cpp +++ b/src/openvic-simulation/map/Building.cpp @@ -105,7 +105,7 @@ bool Building::spawned_railway_track() const { return spawn_railway_track; } -BuildingType::BuildingType(const std::string_view new_identifier) : HasIdentifier { new_identifier } {} +BuildingType::BuildingType(std::string_view new_identifier) : HasIdentifier { new_identifier } {} BuildingInstance::BuildingInstance(Building const& building) : HasIdentifier { building.get_identifier() }, building { building } {} @@ -176,7 +176,7 @@ void BuildingInstance::tick(Date const& today) { BuildingManager::BuildingManager() : building_types { "building types" }, buildings { "buildings" } {} -bool BuildingManager::add_building_type(const std::string_view identifier) { +bool BuildingManager::add_building_type(std::string_view identifier) { if (identifier.empty()) { Logger::error("Invalid building type identifier - empty!"); return false; diff --git a/src/openvic-simulation/map/Building.hpp b/src/openvic-simulation/map/Building.hpp index 9b11c1c..1c2ded0 100644 --- a/src/openvic-simulation/map/Building.hpp +++ b/src/openvic-simulation/map/Building.hpp @@ -103,7 +103,7 @@ namespace OpenVic { friend struct BuildingManager; private: - BuildingType(const std::string_view new_identifier); + BuildingType(std::string_view new_identifier); public: BuildingType(BuildingType&&) = default; @@ -161,7 +161,7 @@ namespace OpenVic { public: BuildingManager(); - bool add_building_type(const std::string_view identifier); + bool add_building_type(std::string_view identifier); IDENTIFIER_REGISTRY_ACCESSORS(BuildingType, building_type) bool add_building(std::string_view identifier, ARGS); diff --git a/src/openvic-simulation/map/Map.cpp b/src/openvic-simulation/map/Map.cpp index 7ecff39..386e7be 100644 --- a/src/openvic-simulation/map/Map.cpp +++ b/src/openvic-simulation/map/Map.cpp @@ -10,7 +10,7 @@ using namespace OpenVic; using namespace OpenVic::NodeTools; -Mapmode::Mapmode(const std::string_view new_identifier, index_t new_index, colour_func_t new_colour_func) +Mapmode::Mapmode(std::string_view new_identifier, index_t new_index, colour_func_t new_colour_func) : HasIdentifier { new_identifier }, index { new_index }, colour_func { new_colour_func } { @@ -32,7 +32,7 @@ Map::Map() : provinces { "provinces" }, regions { "regions" }, mapmodes { "mapmodes" } {} -bool Map::add_province(const std::string_view identifier, colour_t colour) { +bool Map::add_province(std::string_view identifier, colour_t colour) { if (provinces.size() >= max_provinces) { Logger::error("The map's province list is full - maximum number of provinces is ", max_provinces, " (this can be at most ", Province::MAX_INDEX, ")"); return false; @@ -55,7 +55,7 @@ bool Map::add_province(const std::string_view identifier, colour_t colour) { return provinces.add_item(std::move(new_province)); } -bool Map::set_water_province(const std::string_view identifier) { +bool Map::set_water_province(std::string_view identifier) { if (water_provinces.is_locked()) { Logger::error("The map's water provinces have already been locked!"); return false; @@ -91,7 +91,7 @@ void Map::lock_water_provinces() { Logger::info("Locked water provinces after registering ", water_provinces.size()); } -bool Map::add_region(const std::string_view identifier, std::vector<std::string_view> const& province_identifiers) { +bool Map::add_region(std::string_view identifier, std::vector<std::string_view> const& province_identifiers) { if (identifier.empty()) { Logger::error("Invalid region identifier - empty!"); return false; @@ -203,7 +203,7 @@ TerrainTypeManager const& Map::get_terrain_type_manager() const { return terrain_type_manager; } -bool Map::add_mapmode(const std::string_view identifier, Mapmode::colour_func_t colour_func) { +bool Map::add_mapmode(std::string_view identifier, Mapmode::colour_func_t colour_func) { if (identifier.empty()) { Logger::error("Invalid mapmode identifier - empty!"); return false; diff --git a/src/openvic-simulation/map/Map.hpp b/src/openvic-simulation/map/Map.hpp index 99c0bce..9c97960 100644 --- a/src/openvic-simulation/map/Map.hpp +++ b/src/openvic-simulation/map/Map.hpp @@ -21,7 +21,7 @@ namespace OpenVic { const index_t index; const colour_func_t colour_func; - Mapmode(const std::string_view new_identifier, index_t new_index, colour_func_t new_colour_func); + Mapmode(std::string_view new_identifier, index_t new_index, colour_func_t new_colour_func); public: static const Mapmode ERROR_MAPMODE; @@ -69,11 +69,11 @@ namespace OpenVic { public: Map(); - bool add_province(const std::string_view identifier, colour_t colour); + bool add_province(std::string_view identifier, colour_t colour); IDENTIFIER_REGISTRY_ACCESSORS(Province, province) IDENTIFIER_REGISTRY_NON_CONST_ACCESSORS(Province, province) - bool set_water_province(const std::string_view identifier); + bool set_water_province(std::string_view identifier); bool set_water_province_list(std::vector<std::string_view> const& list); void lock_water_provinces(); @@ -92,11 +92,11 @@ namespace OpenVic { TerrainTypeManager& get_terrain_type_manager(); TerrainTypeManager const& get_terrain_type_manager() const; - bool add_region(const std::string_view identifier, std::vector<std::string_view> const& province_identifiers); + bool add_region(std::string_view identifier, std::vector<std::string_view> const& province_identifiers); IDENTIFIER_REGISTRY_ACCESSORS(Region, region) IDENTIFIER_REGISTRY_NON_CONST_ACCESSORS(Region, region) - bool add_mapmode(const std::string_view identifier, Mapmode::colour_func_t colour_func); + bool add_mapmode(std::string_view identifier, Mapmode::colour_func_t colour_func); IDENTIFIER_REGISTRY_ACCESSORS(Mapmode, mapmode) Mapmode const* get_mapmode_by_index(size_t index) const; static constexpr size_t MAPMODE_COLOUR_SIZE = 4; diff --git a/src/openvic-simulation/map/Province.cpp b/src/openvic-simulation/map/Province.cpp index 21bdb85..fa514eb 100644 --- a/src/openvic-simulation/map/Province.cpp +++ b/src/openvic-simulation/map/Province.cpp @@ -3,7 +3,7 @@ using namespace OpenVic; using namespace OpenVic::NodeTools; -Province::Province(const std::string_view new_identifier, colour_t new_colour, index_t new_index) +Province::Province(std::string_view new_identifier, colour_t new_colour, index_t new_index) : HasIdentifierAndColour { new_identifier, new_colour, false, false }, index { new_index }, buildings { "buildings", false } { assert(index != NULL_INDEX); @@ -47,7 +47,7 @@ void Province::reset_buildings() { buildings.reset(); } -bool Province::expand_building(const std::string_view building_type_identifier) { +bool Province::expand_building(std::string_view building_type_identifier) { BuildingInstance* building = buildings.get_item_by_identifier(building_type_identifier); if (building == nullptr) return false; return building->expand(); diff --git a/src/openvic-simulation/map/Province.hpp b/src/openvic-simulation/map/Province.hpp index 349c16d..e15d8d3 100644 --- a/src/openvic-simulation/map/Province.hpp +++ b/src/openvic-simulation/map/Province.hpp @@ -60,7 +60,7 @@ namespace OpenVic { void _set_terrain_type(TerrainType const* type); - Province(const std::string_view new_identifier, colour_t new_colour, index_t new_index); + Province(std::string_view new_identifier, colour_t new_colour, index_t new_index); public: Province(Province&&) = default; @@ -76,7 +76,7 @@ namespace OpenVic { bool add_building(BuildingInstance&& building_instance); IDENTIFIER_REGISTRY_ACCESSORS(BuildingInstance, building) void reset_buildings(); - bool expand_building(const std::string_view building_type_identifier); + bool expand_building(std::string_view building_type_identifier); Good const* get_rgo() const; std::string to_string() const; diff --git a/src/openvic-simulation/map/Region.cpp b/src/openvic-simulation/map/Region.cpp index c0422de..477dc9e 100644 --- a/src/openvic-simulation/map/Region.cpp +++ b/src/openvic-simulation/map/Region.cpp @@ -63,7 +63,7 @@ ProvinceSet::provinces_t const& ProvinceSet::get_provinces() const { return provinces; } -Region::Region(const std::string_view new_identifier, provinces_t&& new_provinces, bool new_meta) +Region::Region(std::string_view new_identifier, provinces_t&& new_provinces, bool new_meta) : HasIdentifier { new_identifier }, ProvinceSet { std::move(new_provinces) }, meta { new_meta } { lock(); } diff --git a/src/openvic-simulation/map/Region.hpp b/src/openvic-simulation/map/Region.hpp index d68033b..157b643 100644 --- a/src/openvic-simulation/map/Region.hpp +++ b/src/openvic-simulation/map/Region.hpp @@ -38,7 +38,7 @@ namespace OpenVic { */ const bool meta; - Region(const std::string_view new_identifier, provinces_t&& new_provinces, bool new_meta); + Region(std::string_view new_identifier, provinces_t&& new_provinces, bool new_meta); public: Region(Region&&) = default; diff --git a/src/openvic-simulation/map/TerrainType.cpp b/src/openvic-simulation/map/TerrainType.cpp index e688625..24cfb7d 100644 --- a/src/openvic-simulation/map/TerrainType.cpp +++ b/src/openvic-simulation/map/TerrainType.cpp @@ -5,14 +5,14 @@ using namespace OpenVic; using namespace OpenVic::NodeTools; -TerrainType::TerrainType(const std::string_view new_identifier, colour_t new_colour, ModifierValue&& new_values, bool new_is_water) +TerrainType::TerrainType(std::string_view new_identifier, colour_t new_colour, ModifierValue&& new_values, bool new_is_water) : HasIdentifierAndColour { new_identifier, new_colour, true, false }, ModifierValue { std::move(new_values) }, is_water { new_is_water } {} bool TerrainType::get_is_water() const { return is_water; } -TerrainTypeMapping::TerrainTypeMapping(const std::string_view new_identifier, TerrainType const& new_type, +TerrainTypeMapping::TerrainTypeMapping(std::string_view new_identifier, TerrainType const& new_type, std::vector<index_t>&& new_terrain_indicies, index_t new_priority, bool new_has_texture) : HasIdentifier { new_identifier }, type { new_type }, terrain_indicies { std::move(new_terrain_indicies) }, priority { new_priority }, has_texture { new_has_texture } {} @@ -35,7 +35,7 @@ bool TerrainTypeMapping::get_has_texture() const { TerrainTypeManager::TerrainTypeManager() : terrain_types { "terrain types" }, terrain_type_mappings { "terrain type mappings" } {} -bool TerrainTypeManager::add_terrain_type(const std::string_view identifier, colour_t colour, ModifierValue&& values, bool is_water) { +bool TerrainTypeManager::add_terrain_type(std::string_view identifier, colour_t colour, ModifierValue&& values, bool is_water) { if (identifier.empty()) { Logger::error("Invalid terrain type identifier - empty!"); return false; @@ -47,7 +47,7 @@ bool TerrainTypeManager::add_terrain_type(const std::string_view identifier, col return terrain_types.add_item({ identifier, colour, std::move(values), is_water }); } -bool TerrainTypeManager::add_terrain_type_mapping(const std::string_view identifier, TerrainType const* type, +bool TerrainTypeManager::add_terrain_type_mapping(std::string_view identifier, TerrainType const* type, std::vector<TerrainTypeMapping::index_t>&& terrain_indicies, TerrainTypeMapping::index_t priority, bool has_texture) { if (!terrain_types.is_locked()) { Logger::error("Cannot register terrain type mappings until terrain types are locked!"); diff --git a/src/openvic-simulation/map/TerrainType.hpp b/src/openvic-simulation/map/TerrainType.hpp index 0cc28c2..3b491ae 100644 --- a/src/openvic-simulation/map/TerrainType.hpp +++ b/src/openvic-simulation/map/TerrainType.hpp @@ -11,7 +11,7 @@ namespace OpenVic { private: const bool is_water; - TerrainType(const std::string_view new_identifier, colour_t new_colour, ModifierValue&& new_values, bool new_is_water); + TerrainType(std::string_view new_identifier, colour_t new_colour, ModifierValue&& new_values, bool new_is_water); public: TerrainType(TerrainType&&) = default; @@ -30,7 +30,7 @@ namespace OpenVic { const index_t priority; const bool has_texture; - TerrainTypeMapping(const std::string_view new_identifier, TerrainType const& new_type, std::vector<index_t>&& new_terrain_indicies, index_t new_priority, bool new_has_texture); + TerrainTypeMapping(std::string_view new_identifier, TerrainType const& new_type, std::vector<index_t>&& new_terrain_indicies, index_t new_priority, bool new_has_texture); public: TerrainTypeMapping(TerrainTypeMapping&&) = default; @@ -56,10 +56,10 @@ namespace OpenVic { public: TerrainTypeManager(); - bool add_terrain_type(const std::string_view identifier, colour_t colour, ModifierValue&& values, bool is_water); + bool add_terrain_type(std::string_view identifier, colour_t colour, ModifierValue&& values, bool is_water); IDENTIFIER_REGISTRY_ACCESSORS(TerrainType, terrain_type) - bool add_terrain_type_mapping(const std::string_view identifier, TerrainType const* type, + bool add_terrain_type_mapping(std::string_view identifier, TerrainType const* type, std::vector<TerrainTypeMapping::index_t>&& terrain_indicies, TerrainTypeMapping::index_t priority, bool has_texture); IDENTIFIER_REGISTRY_ACCESSORS(TerrainTypeMapping, terrain_type_mapping) diff --git a/src/openvic-simulation/politics/Ideology.cpp b/src/openvic-simulation/politics/Ideology.cpp index 7c15c3c..5b2c0ef 100644 --- a/src/openvic-simulation/politics/Ideology.cpp +++ b/src/openvic-simulation/politics/Ideology.cpp @@ -3,9 +3,9 @@ using namespace OpenVic; using namespace OpenVic::NodeTools; -IdeologyGroup::IdeologyGroup(const std::string_view new_identifier) : HasIdentifier { new_identifier } {} +IdeologyGroup::IdeologyGroup(std::string_view new_identifier) : HasIdentifier { new_identifier } {} -Ideology::Ideology(const std::string_view new_identifier, colour_t new_colour, IdeologyGroup const& new_group, bool new_uncivilised, bool new_can_reduce_militancy, Date new_spawn_date) +Ideology::Ideology(std::string_view new_identifier, colour_t new_colour, IdeologyGroup const& new_group, bool new_uncivilised, bool new_can_reduce_militancy, Date new_spawn_date) : HasIdentifierAndColour { new_identifier, new_colour, true, false }, group { new_group }, uncivilised { new_uncivilised }, can_reduce_militancy { new_can_reduce_militancy }, spawn_date { new_spawn_date } {} @@ -27,7 +27,7 @@ Date const& Ideology::get_spawn_date() const { IdeologyManager::IdeologyManager() : ideology_groups { "ideology groups" }, ideologies { "ideologies" } {} -bool IdeologyManager::add_ideology_group(const std::string_view identifier) { +bool IdeologyManager::add_ideology_group(std::string_view identifier) { if (identifier.empty()) { Logger::error("Invalid ideology group identifier - empty!"); return false; @@ -36,7 +36,7 @@ bool IdeologyManager::add_ideology_group(const std::string_view identifier) { return ideology_groups.add_item({ identifier }); } -bool IdeologyManager::add_ideology(const std::string_view identifier, colour_t colour, IdeologyGroup const* group, bool uncivilised, bool can_reduce_militancy, Date spawn_date) { +bool IdeologyManager::add_ideology(std::string_view identifier, colour_t colour, IdeologyGroup const* group, bool uncivilised, bool can_reduce_militancy, Date spawn_date) { if (identifier.empty()) { Logger::error("Invalid ideology identifier - empty!"); return false; diff --git a/src/openvic-simulation/politics/Ideology.hpp b/src/openvic-simulation/politics/Ideology.hpp index e9989c8..ab761b1 100644 --- a/src/openvic-simulation/politics/Ideology.hpp +++ b/src/openvic-simulation/politics/Ideology.hpp @@ -9,7 +9,7 @@ namespace OpenVic { friend struct IdeologyManager; private: - IdeologyGroup(const std::string_view new_identifier); + IdeologyGroup(std::string_view new_identifier); public: IdeologyGroup(IdeologyGroup&&) = default; @@ -25,7 +25,7 @@ namespace OpenVic { //TODO - willingness to repeal/pass reforms (and its modifiers) - Ideology(const std::string_view new_identifier, colour_t new_colour, IdeologyGroup const& new_group, bool new_uncivilised, bool new_can_reduce_militancy, Date new_spawn_date); + Ideology(std::string_view new_identifier, colour_t new_colour, IdeologyGroup const& new_group, bool new_uncivilised, bool new_can_reduce_militancy, Date new_spawn_date); public: Ideology(Ideology&&) = default; @@ -44,10 +44,10 @@ namespace OpenVic { public: IdeologyManager(); - bool add_ideology_group(const std::string_view identifier); + bool add_ideology_group(std::string_view identifier); IDENTIFIER_REGISTRY_ACCESSORS(IdeologyGroup, ideology_group) - bool add_ideology(const std::string_view identifier, colour_t colour, IdeologyGroup const* group, bool uncivilised, bool can_reduce_militancy, Date spawn_date); + bool add_ideology(std::string_view identifier, colour_t colour, IdeologyGroup const* group, bool uncivilised, bool can_reduce_militancy, Date spawn_date); IDENTIFIER_REGISTRY_ACCESSORS_CUSTOM_PLURAL(Ideology, ideology, ideologies) bool load_ideology_file(ast::NodeCPtr root); diff --git a/src/openvic-simulation/politics/Issue.cpp b/src/openvic-simulation/politics/Issue.cpp index 67b3783..73978ee 100644 --- a/src/openvic-simulation/politics/Issue.cpp +++ b/src/openvic-simulation/politics/Issue.cpp @@ -3,19 +3,19 @@ using namespace OpenVic; using namespace OpenVic::NodeTools; -IssueGroup::IssueGroup(const std::string_view new_identifier) : HasIdentifier { new_identifier } {} +IssueGroup::IssueGroup(std::string_view new_identifier) : HasIdentifier { new_identifier } {} -Issue::Issue(const std::string_view identifier, IssueGroup const& group) +Issue::Issue(std::string_view identifier, IssueGroup const& group) : HasIdentifier { identifier }, group { group } {} IssueGroup const& Issue::get_group() const { return group; } -ReformType::ReformType(const std::string_view new_identifier, bool uncivilised) +ReformType::ReformType(std::string_view new_identifier, bool uncivilised) : HasIdentifier { new_identifier }, uncivilised { uncivilised } {} -ReformGroup::ReformGroup(const std::string_view identifier, ReformType const& type, bool ordered, bool administrative) +ReformGroup::ReformGroup(std::string_view identifier, ReformType const& type, bool ordered, bool administrative) : IssueGroup { identifier }, type { type }, ordered { ordered }, administrative { administrative } {} ReformType const& ReformGroup::get_type() const { @@ -30,7 +30,7 @@ bool ReformGroup::is_administrative() const { return administrative; } -Reform::Reform(const std::string_view identifier, ReformGroup const& group, size_t ordinal) +Reform::Reform(std::string_view identifier, ReformGroup const& group, size_t ordinal) : Issue { identifier, group }, ordinal { ordinal }, reform_group { group } {} ReformGroup const& Reform::get_reform_group() const { @@ -48,7 +48,7 @@ size_t Reform::get_ordinal() const { IssueManager::IssueManager() : issue_groups { "issue groups" }, issues { "issues" }, reform_types { "reform types" }, reform_groups { "reform groups" }, reforms { "reforms" } {} -bool IssueManager::add_issue_group(const std::string_view identifier) { +bool IssueManager::add_issue_group(std::string_view identifier) { if (identifier.empty()) { Logger::error("Invalid issue group identifier - empty!"); return false; @@ -57,7 +57,7 @@ bool IssueManager::add_issue_group(const std::string_view identifier) { return issue_groups.add_item({ identifier }); } -bool IssueManager::add_issue(const std::string_view identifier, IssueGroup const* group) { +bool IssueManager::add_issue(std::string_view identifier, IssueGroup const* group) { if (identifier.empty()) { Logger::error("Invalid issue identifier - empty!"); return false; @@ -71,7 +71,7 @@ bool IssueManager::add_issue(const std::string_view identifier, IssueGroup const return issues.add_item({ identifier, *group }); } -bool IssueManager::add_reform_type(const std::string_view identifier, bool uncivilised) { +bool IssueManager::add_reform_type(std::string_view identifier, bool uncivilised) { if (identifier.empty()) { Logger::error("Invalid issue type identifier - empty!"); return false; @@ -80,7 +80,7 @@ bool IssueManager::add_reform_type(const std::string_view identifier, bool unciv return reform_types.add_item({ identifier, uncivilised }); } -bool IssueManager::add_reform_group(const std::string_view identifier, ReformType const* type, bool ordered, bool administrative) { +bool IssueManager::add_reform_group(std::string_view identifier, ReformType const* type, bool ordered, bool administrative) { if (identifier.empty()) { Logger::error("Invalid issue group identifier - empty!"); return false; @@ -94,7 +94,7 @@ bool IssueManager::add_reform_group(const std::string_view identifier, ReformTyp return reform_groups.add_item({ identifier, *type, ordered, administrative }); } -bool IssueManager::add_reform(const std::string_view identifier, ReformGroup const* group, size_t ordinal) { +bool IssueManager::add_reform(std::string_view identifier, ReformGroup const* group, size_t ordinal) { if (identifier.empty()) { Logger::error("Invalid issue identifier - empty!"); return false; @@ -108,19 +108,19 @@ bool IssueManager::add_reform(const std::string_view identifier, ReformGroup con return reforms.add_item({ identifier, *group, ordinal }); } -bool IssueManager::_load_issue_group(size_t& expected_issues, const std::string_view identifier, ast::NodeCPtr node) { +bool IssueManager::_load_issue_group(size_t& expected_issues, std::string_view identifier, ast::NodeCPtr node) { return expect_length([&expected_issues](size_t size) -> size_t { expected_issues += size; return size; })(node) & add_issue_group(identifier); } -bool IssueManager::_load_issue(const std::string_view identifier, IssueGroup const* group, ast::NodeCPtr node) { +bool IssueManager::_load_issue(std::string_view identifier, IssueGroup const* group, ast::NodeCPtr node) { //TODO: policy modifiers, policy rule changes return add_issue(identifier, group); } -bool IssueManager::_load_reform_group(size_t& expected_reforms, const std::string_view identifier, ReformType const* type, ast::NodeCPtr node) { +bool IssueManager::_load_reform_group(size_t& expected_reforms, std::string_view identifier, ReformType const* type, ast::NodeCPtr node) { bool ordered = false, administrative = false; bool ret = expect_dictionary_keys_and_length( [&expected_reforms](size_t size) -> size_t { @@ -134,7 +134,7 @@ bool IssueManager::_load_reform_group(size_t& expected_reforms, const std::strin return ret; } -bool IssueManager::_load_reform(size_t& ordinal, const std::string_view identifier, ReformGroup const* group, ast::NodeCPtr node) { +bool IssueManager::_load_reform(size_t& ordinal, std::string_view identifier, ReformGroup const* group, ast::NodeCPtr node) { //TODO: conditions to allow, policy modifiers, policy rule changes return add_reform(identifier, group, ordinal); } diff --git a/src/openvic-simulation/politics/Issue.hpp b/src/openvic-simulation/politics/Issue.hpp index 66e8d1a..ddd6295 100644 --- a/src/openvic-simulation/politics/Issue.hpp +++ b/src/openvic-simulation/politics/Issue.hpp @@ -14,7 +14,7 @@ namespace OpenVic { friend struct IssueManager; protected: - IssueGroup(const std::string_view identifier); + IssueGroup(std::string_view identifier); public: IssueGroup(IssueGroup&&) = default; @@ -30,7 +30,7 @@ namespace OpenVic { //TODO: policy modifiers, policy rule changes protected: - Issue(const std::string_view identifier, IssueGroup const& group); + Issue(std::string_view identifier, IssueGroup const& group); public: Issue(Issue&&) = default; @@ -45,7 +45,7 @@ namespace OpenVic { bool uncivilised; //whether this group is available to non-westernised countries //in vanilla education, military and economic reforms are hardcoded to true and the rest to false - ReformType(const std::string_view new_identifier, bool uncivilised); + ReformType(std::string_view new_identifier, bool uncivilised); public: ReformType(ReformType&&) = default; @@ -60,7 +60,7 @@ namespace OpenVic { const bool ordered; //next_step_only const bool administrative; - ReformGroup(const std::string_view identifier, ReformType const& type, bool ordered, bool administrative); + ReformGroup(std::string_view identifier, ReformType const& type, bool ordered, bool administrative); public: ReformGroup(ReformGroup&&) = default; @@ -77,7 +77,7 @@ namespace OpenVic { ReformGroup const& reform_group; //stores an already casted reference const size_t ordinal; //assigned by the parser to allow policy sorting - Reform(const std::string_view new_identifier, ReformGroup const& group, size_t ordinal); + Reform(std::string_view new_identifier, ReformGroup const& group, size_t ordinal); //TODO: conditions to allow, @@ -97,28 +97,28 @@ namespace OpenVic { IdentifierRegistry<ReformGroup> reform_groups; IdentifierRegistry<Reform> reforms; - bool _load_issue_group(size_t& expected_issues, const std::string_view identifier, ast::NodeCPtr node); - bool _load_issue(const std::string_view identifier, IssueGroup const* group, ast::NodeCPtr node); - bool _load_reform_group(size_t& expected_reforms, const std::string_view identifier, ReformType const* type, + bool _load_issue_group(size_t& expected_issues, std::string_view identifier, ast::NodeCPtr node); + bool _load_issue(std::string_view identifier, IssueGroup const* group, ast::NodeCPtr node); + bool _load_reform_group(size_t& expected_reforms, std::string_view identifier, ReformType const* type, ast::NodeCPtr node); - bool _load_reform(size_t& ordinal, const std::string_view identifier, ReformGroup const* group, ast::NodeCPtr node); + bool _load_reform(size_t& ordinal, std::string_view identifier, ReformGroup const* group, ast::NodeCPtr node); public: IssueManager(); - bool add_issue_group(const std::string_view identifier); + bool add_issue_group(std::string_view identifier); IDENTIFIER_REGISTRY_ACCESSORS(IssueGroup, issue_group) - bool add_issue(const std::string_view identifier, IssueGroup const* group); + bool add_issue(std::string_view identifier, IssueGroup const* group); IDENTIFIER_REGISTRY_ACCESSORS(Issue, issue) - bool add_reform_type(const std::string_view identifier, bool uncivilised); + bool add_reform_type(std::string_view identifier, bool uncivilised); IDENTIFIER_REGISTRY_ACCESSORS(ReformType, reform_type) - bool add_reform_group(const std::string_view identifier, ReformType const* type, bool ordered, bool administrative); + bool add_reform_group(std::string_view identifier, ReformType const* type, bool ordered, bool administrative); IDENTIFIER_REGISTRY_ACCESSORS(ReformGroup, reform_group) - bool add_reform(const std::string_view identifier, ReformGroup const* group, size_t ordinal); + bool add_reform(std::string_view identifier, ReformGroup const* group, size_t ordinal); IDENTIFIER_REGISTRY_ACCESSORS(Reform, reform) bool load_issues_file(ast::NodeCPtr root); diff --git a/src/openvic-simulation/pop/Culture.cpp b/src/openvic-simulation/pop/Culture.cpp index 69e1543..6285305 100644 --- a/src/openvic-simulation/pop/Culture.cpp +++ b/src/openvic-simulation/pop/Culture.cpp @@ -7,9 +7,9 @@ using namespace OpenVic; using namespace OpenVic::NodeTools; -GraphicalCultureType::GraphicalCultureType(const std::string_view new_identifier) : HasIdentifier { new_identifier } {} +GraphicalCultureType::GraphicalCultureType(std::string_view new_identifier) : HasIdentifier { new_identifier } {} -CultureGroup::CultureGroup(const std::string_view new_identifier, const std::string_view new_leader, +CultureGroup::CultureGroup(std::string_view new_identifier, std::string_view new_leader, GraphicalCultureType const& new_unit_graphical_culture_type, bool new_is_overseas) : HasIdentifier { new_identifier }, leader { new_leader }, unit_graphical_culture_type { new_unit_graphical_culture_type }, @@ -27,7 +27,7 @@ bool CultureGroup::get_is_overseas() const { return is_overseas; } -Culture::Culture(const std::string_view new_identifier, colour_t new_colour, CultureGroup const& new_group, +Culture::Culture(std::string_view new_identifier, colour_t new_colour, CultureGroup const& new_group, std::vector<std::string> const& new_first_names, std::vector<std::string> const& new_last_names) : HasIdentifierAndColour { new_identifier, new_colour, true, false }, group { new_group }, @@ -51,7 +51,7 @@ CultureManager::CultureManager() culture_groups { "culture groups" }, cultures { "cultures" } {} -bool CultureManager::add_graphical_culture_type(const std::string_view identifier) { +bool CultureManager::add_graphical_culture_type(std::string_view identifier) { if (identifier.empty()) { Logger::error("Invalid culture group identifier - empty!"); return false; @@ -59,7 +59,7 @@ bool CultureManager::add_graphical_culture_type(const std::string_view identifie return graphical_culture_types.add_item({ identifier }); } -bool CultureManager::add_culture_group(const std::string_view identifier, const std::string_view leader, GraphicalCultureType const* graphical_culture_type, bool is_overseas) { +bool CultureManager::add_culture_group(std::string_view identifier, std::string_view leader, GraphicalCultureType const* graphical_culture_type, bool is_overseas) { if (!graphical_culture_types.is_locked()) { Logger::error("Cannot register culture groups until graphical culture types are locked!"); return false; @@ -79,7 +79,7 @@ bool CultureManager::add_culture_group(const std::string_view identifier, const return culture_groups.add_item({ identifier, leader, *graphical_culture_type, is_overseas }); } -bool CultureManager::add_culture(const std::string_view identifier, colour_t colour, CultureGroup const* group, std::vector<std::string> const& first_names, std::vector<std::string> const& last_names) { +bool CultureManager::add_culture(std::string_view identifier, colour_t colour, CultureGroup const* group, std::vector<std::string> const& first_names, std::vector<std::string> const& last_names) { if (!culture_groups.is_locked()) { Logger::error("Cannot register cultures until culture groups are locked!"); return false; @@ -112,7 +112,7 @@ bool CultureManager::load_graphical_culture_type_file(ast::NodeCPtr root) { bool CultureManager::_load_culture_group(size_t& total_expected_cultures, GraphicalCultureType const* default_unit_graphical_culture_type, - const std::string_view culture_group_key, ast::NodeCPtr culture_group_node) { + std::string_view culture_group_key, ast::NodeCPtr culture_group_node) { std::string_view leader; GraphicalCultureType const* unit_graphical_culture_type = default_unit_graphical_culture_type; @@ -134,7 +134,7 @@ bool CultureManager::_load_culture_group(size_t& total_expected_cultures, } bool CultureManager::_load_culture(CultureGroup const* culture_group, - const std::string_view culture_key, ast::NodeCPtr culture_node) { + std::string_view culture_key, ast::NodeCPtr culture_node) { colour_t colour = NULL_COLOUR; std::vector<std::string> first_names, last_names; diff --git a/src/openvic-simulation/pop/Culture.hpp b/src/openvic-simulation/pop/Culture.hpp index d27c7c9..becc289 100644 --- a/src/openvic-simulation/pop/Culture.hpp +++ b/src/openvic-simulation/pop/Culture.hpp @@ -10,7 +10,7 @@ namespace OpenVic { friend struct CultureManager; private: - GraphicalCultureType(const std::string_view new_identifier); + GraphicalCultureType(std::string_view new_identifier); public: GraphicalCultureType(GraphicalCultureType&&) = default; @@ -26,7 +26,7 @@ namespace OpenVic { // TODO - union tag - CultureGroup(const std::string_view new_identifier, const std::string_view new_leader, GraphicalCultureType const& new_unit_graphical_culture_type, bool new_is_overseas); + CultureGroup(std::string_view new_identifier, std::string_view new_leader, GraphicalCultureType const& new_unit_graphical_culture_type, bool new_is_overseas); public: CultureGroup(CultureGroup&&) = default; @@ -45,7 +45,7 @@ namespace OpenVic { // TODO - radicalism, primary tag - Culture(const std::string_view new_identifier, colour_t new_colour, CultureGroup const& new_group, std::vector<std::string> const& new_first_names, std::vector<std::string> const& new_last_names); + Culture(std::string_view new_identifier, colour_t new_colour, CultureGroup const& new_group, std::vector<std::string> const& new_first_names, std::vector<std::string> const& new_last_names); public: Culture(Culture&&) = default; @@ -62,19 +62,19 @@ namespace OpenVic { IdentifierRegistry<Culture> cultures; bool _load_culture_group(size_t& total_expected_cultures, GraphicalCultureType const* default_unit_graphical_culture_type, - const std::string_view culture_group_key, ast::NodeCPtr culture_group_node); - bool _load_culture(CultureGroup const* culture_group, const std::string_view culture_key, ast::NodeCPtr node); + std::string_view culture_group_key, ast::NodeCPtr culture_group_node); + bool _load_culture(CultureGroup const* culture_group, std::string_view culture_key, ast::NodeCPtr node); public: CultureManager(); - bool add_graphical_culture_type(const std::string_view identifier); + bool add_graphical_culture_type(std::string_view identifier); IDENTIFIER_REGISTRY_ACCESSORS(GraphicalCultureType, graphical_culture_type) - bool add_culture_group(const std::string_view identifier, const std::string_view leader, GraphicalCultureType const* new_graphical_culture_type, bool is_overseas); + bool add_culture_group(std::string_view identifier, std::string_view leader, GraphicalCultureType const* new_graphical_culture_type, bool is_overseas); IDENTIFIER_REGISTRY_ACCESSORS(CultureGroup, culture_group) - bool add_culture(const std::string_view identifier, colour_t colour, CultureGroup const* group, std::vector<std::string> const& first_names, std::vector<std::string> const& last_names); + bool add_culture(std::string_view identifier, colour_t colour, CultureGroup const* group, std::vector<std::string> const& first_names, std::vector<std::string> const& last_names); IDENTIFIER_REGISTRY_ACCESSORS(Culture, culture) bool load_graphical_culture_type_file(ast::NodeCPtr root); diff --git a/src/openvic-simulation/pop/Pop.cpp b/src/openvic-simulation/pop/Pop.cpp index d51233b..17bacbf 100644 --- a/src/openvic-simulation/pop/Pop.cpp +++ b/src/openvic-simulation/pop/Pop.cpp @@ -49,7 +49,7 @@ Pop::pop_size_t Pop::get_pop_daily_change() const { return Pop::get_num_promoted() - (Pop::get_num_demoted() + Pop::get_num_migrated()); } -PopType::PopType(const std::string_view new_identifier, colour_t new_colour, +PopType::PopType(std::string_view new_identifier, colour_t new_colour, strata_t new_strata, sprite_t new_sprite, Pop::pop_size_t new_max_size, Pop::pop_size_t new_merge_max_size, bool new_state_capital_only, bool new_demote_migrant, bool new_is_artisan, bool new_is_slave) @@ -117,7 +117,7 @@ ReligionManager const& PopManager::get_religion_manager() const { return religion_manager; } -bool PopManager::add_pop_type(const std::string_view identifier, colour_t colour, PopType::strata_t strata, PopType::sprite_t sprite, +bool PopManager::add_pop_type(std::string_view identifier, colour_t colour, PopType::strata_t strata, PopType::sprite_t sprite, Pop::pop_size_t max_size, Pop::pop_size_t merge_max_size, bool state_capital_only, bool demote_migrant, bool is_artisan, bool is_slave) { if (identifier.empty()) { Logger::error("Invalid pop type identifier - empty!"); @@ -145,7 +145,7 @@ bool PopManager::add_pop_type(const std::string_view identifier, colour_t colour /* REQUIREMENTS: * POP-3, POP-4, POP-5, POP-6, POP-7, POP-8, POP-9, POP-10, POP-11, POP-12, POP-13, POP-14 */ -bool PopManager::load_pop_type_file(const std::string_view filestem, ast::NodeCPtr root) { +bool PopManager::load_pop_type_file(std::string_view filestem, ast::NodeCPtr root) { colour_t colour = NULL_COLOUR; PopType::strata_t strata = PopType::strata_t::POOR; PopType::sprite_t sprite = 0; @@ -210,7 +210,7 @@ bool PopManager::load_pop_type_file(const std::string_view filestem, ast::NodeCP return ret; } -bool PopManager::load_pop_into_province(Province& province, const std::string_view pop_type_identifier, ast::NodeCPtr pop_node) const { +bool PopManager::load_pop_into_province(Province& province, std::string_view pop_type_identifier, ast::NodeCPtr pop_node) const { PopType const* type = get_pop_type_by_identifier(pop_type_identifier); Culture const* culture = nullptr; Religion const* religion = nullptr; diff --git a/src/openvic-simulation/pop/Pop.hpp b/src/openvic-simulation/pop/Pop.hpp index 85d4504..0ab3d06 100644 --- a/src/openvic-simulation/pop/Pop.hpp +++ b/src/openvic-simulation/pop/Pop.hpp @@ -60,7 +60,7 @@ namespace OpenVic { // TODO - rebel composition, life/everyday/luxury needs, country and province migration targets, promote_to targets, ideologies and issues - PopType(const std::string_view new_identifier, colour_t new_colour, strata_t new_strata, sprite_t new_sprite, Pop::pop_size_t new_max_size, Pop::pop_size_t new_merge_max_size, + PopType(std::string_view new_identifier, colour_t new_colour, strata_t new_strata, sprite_t new_sprite, Pop::pop_size_t new_max_size, Pop::pop_size_t new_merge_max_size, bool new_state_capital_only, bool new_demote_migrant, bool new_is_artisan, bool new_is_slave); public: @@ -93,12 +93,12 @@ namespace OpenVic { ReligionManager& get_religion_manager(); ReligionManager const& get_religion_manager() const; - bool add_pop_type(const std::string_view identifier, colour_t new_colour, PopType::strata_t strata, PopType::sprite_t sprite, + bool add_pop_type(std::string_view identifier, colour_t new_colour, PopType::strata_t strata, PopType::sprite_t sprite, Pop::pop_size_t max_size, Pop::pop_size_t merge_max_size, bool state_capital_only, bool demote_migrant, bool is_artisan, bool is_slave); IDENTIFIER_REGISTRY_ACCESSORS(PopType, pop_type) - bool load_pop_type_file(const std::string_view filestem, ast::NodeCPtr root); - bool load_pop_into_province(Province& province, const std::string_view pop_type_identifier, ast::NodeCPtr pop_node) const; + bool load_pop_type_file(std::string_view filestem, ast::NodeCPtr root); + bool load_pop_into_province(Province& province, std::string_view pop_type_identifier, ast::NodeCPtr pop_node) const; }; } diff --git a/src/openvic-simulation/pop/Religion.cpp b/src/openvic-simulation/pop/Religion.cpp index acdcad0..c679e00 100644 --- a/src/openvic-simulation/pop/Religion.cpp +++ b/src/openvic-simulation/pop/Religion.cpp @@ -5,9 +5,9 @@ using namespace OpenVic; using namespace OpenVic::NodeTools; -ReligionGroup::ReligionGroup(const std::string_view new_identifier) : HasIdentifier { new_identifier } {} +ReligionGroup::ReligionGroup(std::string_view new_identifier) : HasIdentifier { new_identifier } {} -Religion::Religion(const std::string_view new_identifier, colour_t new_colour, +Religion::Religion(std::string_view new_identifier, colour_t new_colour, ReligionGroup const& new_group, icon_t new_icon, bool new_pagan) : HasIdentifierAndColour { new_identifier, new_colour, true, false }, group { new_group }, @@ -32,7 +32,7 @@ ReligionManager::ReligionManager() : religion_groups { "religion groups" }, religions { "religions" } {} -bool ReligionManager::add_religion_group(const std::string_view identifier) { +bool ReligionManager::add_religion_group(std::string_view identifier) { if (identifier.empty()) { Logger::error("Invalid religion group identifier - empty!"); return false; @@ -40,7 +40,7 @@ bool ReligionManager::add_religion_group(const std::string_view identifier) { return religion_groups.add_item({ identifier }); } -bool ReligionManager::add_religion(const std::string_view identifier, colour_t colour, ReligionGroup const* group, Religion::icon_t icon, bool pagan) { +bool ReligionManager::add_religion(std::string_view identifier, colour_t colour, ReligionGroup const* group, Religion::icon_t icon, bool pagan) { if (!religion_groups.is_locked()) { Logger::error("Cannot register religions until religion groups are locked!"); return false; diff --git a/src/openvic-simulation/pop/Religion.hpp b/src/openvic-simulation/pop/Religion.hpp index 8267659..6d1c205 100644 --- a/src/openvic-simulation/pop/Religion.hpp +++ b/src/openvic-simulation/pop/Religion.hpp @@ -11,7 +11,7 @@ namespace OpenVic { friend struct ReligionManager; private: - ReligionGroup(const std::string_view new_identifier); + ReligionGroup(std::string_view new_identifier); public: ReligionGroup(ReligionGroup&&) = default; @@ -27,7 +27,7 @@ namespace OpenVic { const icon_t icon; const bool pagan; - Religion(const std::string_view new_identifier, colour_t new_colour, ReligionGroup const& new_group, icon_t new_icon, bool new_pagan); + Religion(std::string_view new_identifier, colour_t new_colour, ReligionGroup const& new_group, icon_t new_icon, bool new_pagan); public: Religion(Religion&&) = default; @@ -45,10 +45,10 @@ namespace OpenVic { public: ReligionManager(); - bool add_religion_group(const std::string_view identifier); + bool add_religion_group(std::string_view identifier); IDENTIFIER_REGISTRY_ACCESSORS(ReligionGroup, religion_group) - bool add_religion(const std::string_view identifier, colour_t colour, ReligionGroup const* group, Religion::icon_t icon, bool pagan); + bool add_religion(std::string_view identifier, colour_t colour, ReligionGroup const* group, Religion::icon_t icon, bool pagan); IDENTIFIER_REGISTRY_ACCESSORS(Religion, religion) bool load_religion_file(ast::NodeCPtr root); diff --git a/src/openvic-simulation/types/Date.cpp b/src/openvic-simulation/types/Date.cpp index 203d647..27d554c 100644 --- a/src/openvic-simulation/types/Date.cpp +++ b/src/openvic-simulation/types/Date.cpp @@ -257,6 +257,6 @@ Date Date::from_string(char const* str, size_t length, bool* successful) { return from_string(str, str + length, successful); } -Date Date::from_string(const std::string_view str, bool* successful) { +Date Date::from_string(std::string_view str, bool* successful) { return from_string(str.data(), str.length(), successful); } diff --git a/src/openvic-simulation/types/Date.hpp b/src/openvic-simulation/types/Date.hpp index 601f9dc..b2df666 100644 --- a/src/openvic-simulation/types/Date.hpp +++ b/src/openvic-simulation/types/Date.hpp @@ -90,7 +90,7 @@ namespace OpenVic { // Parsed from string of the form YYYY.MM.DD static Date from_string(char const* str, char const* end, bool* successful = nullptr); static Date from_string(char const* str, size_t length, bool* successful = nullptr); - static Date from_string(const std::string_view str, bool* successful = nullptr); + static Date from_string(std::string_view str, bool* successful = nullptr); }; std::ostream& operator<<(std::ostream& out, Date const& date); } diff --git a/src/openvic-simulation/types/IdentifierRegistry.cpp b/src/openvic-simulation/types/IdentifierRegistry.cpp index f284164..d6afd3a 100644 --- a/src/openvic-simulation/types/IdentifierRegistry.cpp +++ b/src/openvic-simulation/types/IdentifierRegistry.cpp @@ -4,7 +4,7 @@ using namespace OpenVic; -HasIdentifier::HasIdentifier(const std::string_view new_identifier) +HasIdentifier::HasIdentifier(std::string_view new_identifier) : identifier { new_identifier } { assert(!identifier.empty()); } @@ -31,7 +31,7 @@ std::string HasColour::colour_to_hex_string() const { return OpenVic::colour_to_hex_string(colour); } -HasIdentifierAndColour::HasIdentifierAndColour(const std::string_view new_identifier, +HasIdentifierAndColour::HasIdentifierAndColour(std::string_view new_identifier, const colour_t new_colour, bool can_be_null, bool can_have_alpha) : HasIdentifier { new_identifier }, HasColour { new_colour, can_be_null, can_have_alpha } {} diff --git a/src/openvic-simulation/types/IdentifierRegistry.hpp b/src/openvic-simulation/types/IdentifierRegistry.hpp index 41e4c6b..482e917 100644 --- a/src/openvic-simulation/types/IdentifierRegistry.hpp +++ b/src/openvic-simulation/types/IdentifierRegistry.hpp @@ -16,7 +16,7 @@ namespace OpenVic { const std::string identifier; protected: - HasIdentifier(const std::string_view new_identifier); + HasIdentifier(std::string_view new_identifier); public: HasIdentifier(HasIdentifier const&) = delete; @@ -55,7 +55,7 @@ namespace OpenVic { */ class HasIdentifierAndColour : public HasIdentifier, public HasColour { protected: - HasIdentifierAndColour(const std::string_view new_identifier, const colour_t new_colour, bool can_be_null, bool can_have_alpha); + HasIdentifierAndColour(std::string_view new_identifier, const colour_t new_colour, bool can_be_null, bool can_have_alpha); public: HasIdentifierAndColour(HasIdentifierAndColour const&) = delete; @@ -86,7 +86,7 @@ namespace OpenVic { identifier_index_map_t identifier_index_map; public: - IdentifierRegistry(const std::string_view new_name, bool new_log_lock = true) + IdentifierRegistry(std::string_view new_name, bool new_log_lock = true) : name { new_name }, log_lock { new_log_lock } {} std::string const& get_name() const { @@ -143,13 +143,13 @@ namespace OpenVic { } } - T* get_item_by_identifier(const std::string_view identifier) { + T* get_item_by_identifier(std::string_view identifier) { const identifier_index_map_t::const_iterator it = identifier_index_map.find(identifier); if (it != identifier_index_map.end()) return &items[it->second]; return nullptr; } - T const* get_item_by_identifier(const std::string_view identifier) const { + T const* get_item_by_identifier(std::string_view identifier) const { const identifier_index_map_t::const_iterator it = identifier_index_map.find(identifier); if (it != identifier_index_map.end()) return &items[it->second]; return nullptr; @@ -242,7 +242,7 @@ namespace OpenVic { #define IDENTIFIER_REGISTRY_ACCESSORS_CUSTOM_PLURAL(type, singular, plural) \ void lock_##plural() { plural.lock(); } \ bool plural##_are_locked() const { return plural.is_locked(); } \ - type const* get_##singular##_by_identifier(const std::string_view identifier) const { \ + type const* get_##singular##_by_identifier(std::string_view identifier) const { \ return plural.get_item_by_identifier(identifier); } \ size_t get_##singular##_count() const { \ return plural.size(); } \ @@ -258,7 +258,7 @@ namespace OpenVic { return plural.expect_item_decimal_map(callback); } #define IDENTIFIER_REGISTRY_NON_CONST_ACCESSORS_CUSTOM_PLURAL(type, singular, plural) \ - type* get_##singular##_by_identifier(const std::string_view identifier) { \ + type* get_##singular##_by_identifier(std::string_view identifier) { \ return plural.get_item_by_identifier(identifier); } \ NodeTools::node_callback_t expect_##singular##_identifier(NodeTools::callback_t<type&> callback) { \ return plural.expect_item_identifier(callback); } \ diff --git a/src/openvic-simulation/types/fixed_point/FixedPoint.hpp b/src/openvic-simulation/types/fixed_point/FixedPoint.hpp index 22fdeca..459d9c4 100644 --- a/src/openvic-simulation/types/fixed_point/FixedPoint.hpp +++ b/src/openvic-simulation/types/fixed_point/FixedPoint.hpp @@ -329,7 +329,7 @@ namespace OpenVic { return parse(str, str + length, successful); } - static fixed_point_t parse(const std::string_view str, bool* successful = nullptr) { + static fixed_point_t parse(std::string_view str, bool* successful = nullptr) { return parse(str.data(), str.length(), successful); } diff --git a/src/openvic-simulation/units/Unit.cpp b/src/openvic-simulation/units/Unit.cpp index b965f93..16719e6 100644 --- a/src/openvic-simulation/units/Unit.cpp +++ b/src/openvic-simulation/units/Unit.cpp @@ -172,7 +172,7 @@ fixed_point_t NavalUnit::get_torpedo_attack() const { UnitManager::UnitManager() : units { "units" } {} -bool UnitManager::_check_shared_parameters(const std::string_view identifier, UNIT_PARAMS) { +bool UnitManager::_check_shared_parameters(std::string_view identifier, UNIT_PARAMS) { if (identifier.empty()) { Logger::error("Invalid religion identifier - empty!"); return false; @@ -193,7 +193,7 @@ bool UnitManager::_check_shared_parameters(const std::string_view identifier, UN return true; } -bool UnitManager::add_land_unit(const std::string_view identifier, UNIT_PARAMS, LAND_PARAMS) { +bool UnitManager::add_land_unit(std::string_view identifier, UNIT_PARAMS, LAND_PARAMS) { if (!_check_shared_parameters(identifier, UNIT_ARGS)) { return false; } @@ -201,7 +201,7 @@ bool UnitManager::add_land_unit(const std::string_view identifier, UNIT_PARAMS, return units.add_item(LandUnit { identifier, UNIT_ARGS, LAND_ARGS }); } -bool UnitManager::add_naval_unit(const std::string_view identifier, UNIT_PARAMS, NAVY_PARAMS) { +bool UnitManager::add_naval_unit(std::string_view identifier, UNIT_PARAMS, NAVY_PARAMS) { if (!_check_shared_parameters(identifier, UNIT_ARGS)) { return false; } diff --git a/src/openvic-simulation/units/Unit.hpp b/src/openvic-simulation/units/Unit.hpp index dc7c00f..979ae70 100644 --- a/src/openvic-simulation/units/Unit.hpp +++ b/src/openvic-simulation/units/Unit.hpp @@ -147,13 +147,13 @@ namespace OpenVic { private: IdentifierRegistry<Unit> units; - bool _check_shared_parameters(const std::string_view identifier, UNIT_PARAMS); + bool _check_shared_parameters(std::string_view identifier, UNIT_PARAMS); public: UnitManager(); - bool add_land_unit(const std::string_view identifier, UNIT_PARAMS, LAND_PARAMS); - bool add_naval_unit(const std::string_view identifier, UNIT_PARAMS, NAVY_PARAMS); + bool add_land_unit(std::string_view identifier, UNIT_PARAMS, LAND_PARAMS); + bool add_naval_unit(std::string_view identifier, UNIT_PARAMS, NAVY_PARAMS); IDENTIFIER_REGISTRY_ACCESSORS(Unit, unit) bool load_unit_file(GoodManager const& good_manager, ast::NodeCPtr root); diff --git a/src/openvic-simulation/utility/StringUtils.hpp b/src/openvic-simulation/utility/StringUtils.hpp index 97efbed..5784208 100644 --- a/src/openvic-simulation/utility/StringUtils.hpp +++ b/src/openvic-simulation/utility/StringUtils.hpp @@ -85,7 +85,7 @@ namespace OpenVic::StringUtils { return string_to_uint64(str, str + length, successful, base); } - inline uint64_t string_to_uint64(const std::string_view str, bool* successful = nullptr, int base = 10) { + inline uint64_t string_to_uint64(std::string_view str, bool* successful = nullptr, int base = 10) { return string_to_uint64(str.data(), str.length(), successful, base); } @@ -121,7 +121,7 @@ namespace OpenVic::StringUtils { return string_to_int64(str, str + length, successful, base); } - inline int64_t string_to_int64(const std::string_view str, bool* successful = nullptr, int base = 10) { + inline int64_t string_to_int64(std::string_view str, bool* successful = nullptr, int base = 10) { return string_to_int64(str.data(), str.length(), successful, base); } } |