OpenTTD Source  20241108-master-g80f628063a
LanguageFileWriter Struct Reference

Class for writing a language to disk. More...

Inheritance diagram for LanguageFileWriter:
LanguageWriter FileWriter SaveFilter

Public Member Functions

 LanguageFileWriter (const std::filesystem::path &path)
 Open a file to write to. More...
 
void WriteHeader (const LanguagePackHeader *header) override
 Write the header metadata. More...
 
void Finalise () override
 Finalise writing the file.
 
void Write (const uint8_t *buffer, size_t length) override
 Write a number of bytes. More...
 
- Public Member Functions inherited from LanguageWriter
virtual ~LanguageWriter ()=default
 Especially destroy the subclasses.
 
virtual void WriteLength (uint length)
 Write the length as a simple gamma. More...
 
virtual void WriteLang (const StringData &data)
 Actually write the language. 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.
 

Additional Inherited Members

- 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

Class for writing a language to disk.

Definition at line 284 of file strgen.cpp.

Constructor & Destructor Documentation

◆ LanguageFileWriter()

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

Open a file to write to.

Parameters
pathThe path to the file to open.

Definition at line 289 of file strgen.cpp.

Member Function Documentation

◆ Write()

void LanguageFileWriter::Write ( const uint8_t *  buffer,
size_t  length 
)
inlineoverridevirtual

Write a number of bytes.

Parameters
bufferThe buffer to write.
lengthThe amount of byte to write.

Implements LanguageWriter.

Definition at line 304 of file strgen.cpp.

References FileWriter::output_stream.

Referenced by WriteHeader().

◆ WriteHeader()

void LanguageFileWriter::WriteHeader ( const LanguagePackHeader header)
inlineoverridevirtual

Write the header metadata.

The multi-byte integers are already converted to the little endian format.

Parameters
headerThe header to write.

Implements LanguageWriter.

Definition at line 293 of file strgen.cpp.

References Write().


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