1 #ifndef _Parse_h_ 2 #define _Parse_h_ 3 4 #if FREEORION_BUILD_PARSE && __GNUC__ 5 # define FO_PARSE_API __attribute__((__visibility__("default"))) 6 #else 7 # define FO_PARSE_API 8 #endif 9 10 #include <boost/filesystem/path.hpp> 11 #include <boost/uuid/uuid.hpp> 12 13 #include "../util/GameRules.h" 14 15 #include <map> 16 #include <set> 17 #include <vector> 18 19 class BuildingType; 20 class FieldType; 21 class FleetPlan; 22 class ShipHull; 23 class MonsterFleetPlan; 24 class ShipPart; 25 struct ParsedShipDesign; 26 class Special; 27 class Species; 28 struct EncyclopediaArticle; 29 struct UnlockableItem; 30 31 namespace ValueRef { 32 template <typename T> 33 struct ValueRef; 34 } 35 36 namespace parse { 37 FO_PARSE_API std::map<std::string, std::unique_ptr<BuildingType>> buildings(const boost::filesystem::path& path); 38 FO_PARSE_API std::map<std::string, std::unique_ptr<FieldType>> fields(const boost::filesystem::path& path); 39 FO_PARSE_API std::map<std::string, std::unique_ptr<Special>> specials(const boost::filesystem::path& path); 40 41 /** Parse all species in directory \p path, store them with their name in \p 42 species_by_name. If a file exists called SpeciesCensusOrdering.focs.txt, parse it and 43 store the census order in \p ordering. */ 44 using species_type = std::pair< 45 std::map<std::string, std::unique_ptr<Species>>, // species_by_name, 46 std::vector<std::string> // ordering 47 >; 48 FO_PARSE_API species_type species(const boost::filesystem::path& path); 49 50 /* T in techs<T> can only be TechManager::TechParseTuple. This decouples 51 Parse.h from Tech.h so that all parsers are not recompiled when Tech.h changes.*/ 52 template <typename T> 53 FO_PARSE_API T techs(const boost::filesystem::path& path); 54 55 FO_PARSE_API std::vector<UnlockableItem> items(const boost::filesystem::path& path); 56 FO_PARSE_API std::vector<UnlockableItem> starting_buildings(const boost::filesystem::path& path); 57 FO_PARSE_API std::map<std::string, std::unique_ptr<ShipPart>> ship_parts(const boost::filesystem::path& path); 58 FO_PARSE_API std::map<std::string, std::unique_ptr<ShipHull>> ship_hulls(const boost::filesystem::path& path); 59 60 /** Parse all ship designs in directory \p path, store them with their filename in \p 61 design_and_path. If a file exists called ShipDesignOrdering.focs.txt, parse it and 62 store the order in \p ordering. */ 63 using ship_designs_type = std::pair< 64 std::vector<std::pair<std::unique_ptr<ParsedShipDesign>, boost::filesystem::path>>, // designs_and_paths, 65 std::vector<boost::uuids::uuid> // ordering 66 >; 67 FO_PARSE_API ship_designs_type ship_designs(const boost::filesystem::path& path); 68 69 FO_PARSE_API std::vector<std::unique_ptr<FleetPlan>> fleet_plans(const boost::filesystem::path& path); 70 FO_PARSE_API std::vector<std::unique_ptr<MonsterFleetPlan>> monster_fleet_plans(const boost::filesystem::path& path); 71 FO_PARSE_API std::map<std::string, std::unique_ptr<ValueRef::ValueRef<double>>> statistics(const boost::filesystem::path& path); 72 FO_PARSE_API std::map<std::string, std::vector<EncyclopediaArticle>> encyclopedia_articles(const boost::filesystem::path& path); 73 FO_PARSE_API GameRules::GameRulesTypeMap game_rules(const boost::filesystem::path& path); 74 FO_PARSE_API bool read_file(const boost::filesystem::path& path, std::string& file_contents); 75 76 FO_PARSE_API void file_substitution(std::string& text, const boost::filesystem::path& file_search_path); 77 FO_PARSE_API void process_include_substitutions(std::string& text, 78 const boost::filesystem::path& file_search_path, 79 std::set<boost::filesystem::path>& files_included); 80 81 FO_PARSE_API bool int_free_variable(std::string& text); 82 FO_PARSE_API bool double_free_variable(std::string& text); 83 FO_PARSE_API bool string_free_variable(std::string& text); 84 } 85 86 #endif 87