MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / FindItemValue

Function FindItemValue

src/settingsgen/settingsgen.cpp:207–213  ·  view source on GitHub ↗

* Find the value of a template variable. * @param name Name of the item to find. * @param grp Group currently being expanded (searched first). * @param defaults Fallback group to search, \c nullptr skips the search. * @return Text of the item if found, else \c std::nullopt. */

Source from the content-addressed store, hash-verified

205 * @return Text of the item if found, else \c std::nullopt.
206 */
207static std::optional<std::string_view> FindItemValue(std::string_view name, const IniGroup *grp, const IniGroup *defaults)
208{
209 const IniItem *item = grp->GetItem(name);
210 if (item == nullptr && defaults != nullptr) item = defaults->GetItem(name);
211 if (item == nullptr) return std::nullopt;
212 return item->value;
213}
214
215/**
216 * Parse a single entry via a template and output this.

Callers 1

DumpLineFunction · 0.85

Calls 1

GetItemMethod · 0.80

Tested by

no test coverage detected