OpenTTD Source  20241121-master-g67a0fccfad
HeaderFileWriter Struct Reference
Inheritance diagram for HeaderFileWriter:
HeaderWriter FileWriter SaveFilter

Public Member Functions

 HeaderFileWriter (const std::filesystem::path &path)
 Open a file to write to. More...
 
void WriteStringID (const std::string &name, int stringid) override
 Write the string ID. More...
 
void Finalise (const StringData &data) override
 Finalise writing the file. More...
 
- Public Member Functions inherited from HeaderWriter
virtual ~HeaderWriter ()=default
 Especially destroy the subclasses.
 
void WriteHeader (const StringData &data)
 Write the header information. More...
 
- Public Member Functions inherited from FileWriter
 FileWriter (FileHandle &&file)
 Create the file writer, so it writes to a specific file. More...
 
 ~FileWriter ()
 Make sure everything is cleaned up.
 
void Write (uint8_t *buf, size_t size) override
 Write a given number of bytes into the savegame. More...
 
void Finish () override
 Prepare everything to finish writing the savegame.
 
 FileWriter (const std::filesystem::path &path, std::ios_base::openmode openmode)
 Open a file to write to. More...
 
void Finalise ()
 Finalise the writing.
 
virtual ~FileWriter ()
 Make sure the file is closed.
 
- Public Member Functions inherited from SaveFilter
 SaveFilter (std::shared_ptr< SaveFilter > chain)
 Initialise this filter. More...
 
virtual ~SaveFilter ()
 Make sure the writers are properly closed.
 

Data Fields

const std::filesystem::path real_path
 The real path we eventually want to write to.
 
int prev
 The previous string ID that was printed.
 
uint total_strings
 
- Data Fields inherited from FileWriter
std::optional< FileHandlefile
 The file to write to.
 
std::ofstream output_stream
 The stream to write all the output to.
 
const std::filesystem::path path
 The file name we're writing to.
 
- Data Fields inherited from SaveFilter
std::shared_ptr< SaveFilterchain
 Chained to the (savegame) filters.
 

Detailed Description

Definition at line 222 of file strgen.cpp.

Constructor & Destructor Documentation

◆ HeaderFileWriter()

HeaderFileWriter::HeaderFileWriter ( const std::filesystem::path &  path)
inline

Open a file to write to.

Parameters
pathThe path to the file to open.

Definition at line 233 of file strgen.cpp.

References FileWriter::output_stream.

Member Function Documentation

◆ Finalise()

void HeaderFileWriter::Finalise ( const StringData data)
inlineoverridevirtual

Finalise writing the file.

Parameters
dataThe data about the string.

Implements HeaderWriter.

Definition at line 249 of file strgen.cpp.

References _plural_forms, CompareFiles(), FileWriter::Finalise(), FileWriter::output_stream, FileWriter::path, and StringData::Version().

◆ WriteStringID()

void HeaderFileWriter::WriteStringID ( const std::string &  name,
int  stringid 
)
inlineoverridevirtual

Write the string ID.

Parameters
nameThe name of the string.
stringidThe ID of the string.

Implements HeaderWriter.

Definition at line 241 of file strgen.cpp.

References FileWriter::output_stream, and prev.


The documentation for this struct was generated from the following file: