11#pragma once
22
3+ #include < initializer_list>
34#include < list>
5+ #include < span>
46#include < string>
57#include < string_view>
68#include < unordered_map>
@@ -87,14 +89,14 @@ class FGD {
8789
8890 FGD () = default ;
8991
90- explicit FGD (const std::string & fgdPath);
92+ explicit FGD (const std::filesystem::path & fgdPath);
9193
9294 /* *
9395 * Can be called multiple times in succession to load multiple FGD files.
9496 * The FGD file data will be merged with previously loaded data.
9597 * @param fgdPath The path to the FGD to load
9698 */
97- void load (const std::string & fgdPath);
99+ void load (const std::filesystem::path & fgdPath);
98100
99101 [[nodiscard]] int getVersion () const ;
100102
@@ -107,7 +109,7 @@ class FGD {
107109 [[nodiscard]] const std::vector<AutoVisGroup>& getAutoVisGroups () const ;
108110
109111protected:
110- void readEntities (BufferStreamReadOnly& stream, const std::string & path, std::vector<std::string >& seenPaths);
112+ void readEntities (BufferStreamReadOnly& stream, const std::filesystem::path & path, std::vector<std::filesystem::path >& seenPaths);
111113
112114 std::list<std::string> backingData;
113115
@@ -124,7 +126,9 @@ class FGDWriter {
124126 public:
125127 explicit AutoVisGroupWriter (FGDWriter& parent_);
126128
127- AutoVisGroupWriter& visGroup (const std::string& name, const std::vector<std::string>& entities);
129+ AutoVisGroupWriter& visGroup (std::string_view name, std::initializer_list<std::string_view> entities);
130+
131+ AutoVisGroupWriter& visGroup (std::string_view name, std::span<const std::string_view> entities);
128132
129133 FGDWriter& endAutoVisGroup () const ; // NOLINT(*-use-nodiscard)
130134
@@ -138,7 +142,7 @@ class FGDWriter {
138142 public:
139143 explicit KeyValueChoicesWriter (EntityWriter& parent_);
140144
141- KeyValueChoicesWriter& choice (const std::string& value, const std::string& displayName);
145+ KeyValueChoicesWriter& choice (std::string_view value, std::string_view displayName);
142146
143147 EntityWriter& endKeyValueChoices () const ; // NOLINT(*-use-nodiscard)
144148
@@ -150,7 +154,7 @@ class FGDWriter {
150154 public:
151155 explicit KeyValueFlagsWriter (EntityWriter& parent_);
152156
153- KeyValueFlagsWriter& flag (uint64_t value, const std::string& displayName, bool enabledByDefault, const std::string& description = " " );
157+ KeyValueFlagsWriter& flag (uint64_t value, std::string_view displayName, bool enabledByDefault, std::string_view description = " " );
154158
155159 EntityWriter& endKeyValueFlags () const ; // NOLINT(*-use-nodiscard)
156160
@@ -160,15 +164,15 @@ class FGDWriter {
160164
161165 explicit EntityWriter (FGDWriter& parent_);
162166
163- EntityWriter& keyValue (const std::string& name, const std::string& valueType, const std::string& displayName = " " , const std::string& valueDefault = " " , const std::string& description = " " , bool readOnly = false , bool report = false );
167+ EntityWriter& keyValue (std::string_view name, std::string_view valueType, std::string_view displayName = " " , std::string_view valueDefault = " " , std::string_view description = " " , bool readOnly = false , bool report = false );
164168
165- KeyValueChoicesWriter beginKeyValueChoices (const std::string& name, const std::string& displayName = " " , const std::string& valueDefault = " " , const std::string& description = " " , bool readOnly = false , bool report = false );
169+ KeyValueChoicesWriter beginKeyValueChoices (std::string_view name, std::string_view displayName = " " , std::string_view valueDefault = " " , std::string_view description = " " , bool readOnly = false , bool report = false );
166170
167- KeyValueFlagsWriter beginKeyValueFlags (const std::string& name, const std::string& displayName = " " , const std::string& description = " " , bool readOnly = false , bool report = false );
171+ KeyValueFlagsWriter beginKeyValueFlags (std::string_view name, std::string_view displayName = " " , std::string_view description = " " , bool readOnly = false , bool report = false );
168172
169- EntityWriter& input (const std::string& name, const std::string& valueType, const std::string& description = " " );
173+ EntityWriter& input (std::string_view name, std::string_view valueType, std::string_view description = " " );
170174
171- EntityWriter& output (const std::string& name, const std::string& valueType, const std::string& description = " " );
175+ EntityWriter& output (std::string_view name, std::string_view valueType, std::string_view description = " " );
172176
173177 FGDWriter& endEntity () const ; // NOLINT(*-use-nodiscard)
174178
@@ -178,21 +182,25 @@ class FGDWriter {
178182
179183 [[nodiscard]] static FGDWriter begin ();
180184
181- FGDWriter& include (const std::string & fgdPath);
185+ FGDWriter& include (const std::filesystem::path & fgdPath);
182186
183187 FGDWriter& version (int version);
184188
185189 FGDWriter& mapSize (sourcepp::math::Vec2i mapSize);
186190
187- FGDWriter& materialExclusionDirs (const std::vector<std::string>& dirs);
191+ FGDWriter& materialExclusionDirs (std::initializer_list<std::string_view> dirs);
192+
193+ FGDWriter& materialExclusionDirs (std::span<const std::string_view> dirs);
194+
195+ AutoVisGroupWriter beginAutoVisGroup (std::string_view parentName);
188196
189- AutoVisGroupWriter beginAutoVisGroup ( const std::string& parentName );
197+ EntityWriter beginEntity (std::string_view classType, std::initializer_list<std::string_view> classProperties, std::string_view name, std::string_view description = " " , std::string_view docsURL = " " );
190198
191- EntityWriter beginEntity (const std::string& classType, const std::vector< std::string>& classProperties, const std::string& name, const std::string& description = " " , const std::string& docsURL = " " );
199+ EntityWriter beginEntity (std::string_view classType, std::span< const std::string_view> classProperties, std::string_view name, std::string_view description = " " , std::string_view docsURL = " " );
192200
193201 [[nodiscard]] std::string bake () const ;
194202
195- bool bake (const std::string & fgdPath) const ; // NOLINT(*-use-nodiscard)
203+ bool bake (const std::filesystem::path & fgdPath) const ; // NOLINT(*-use-nodiscard)
196204
197205protected:
198206 FGDWriter ();
0 commit comments