#include <script_write.h>
Inheritance diagram for hoa_script::WriteScriptDescriptor:


Public Member Functions | |||||||
| ~WriteScriptDescriptor () | |||||||
Comment Write Functions | |||||||
Writes comments into a Lua file
| |||||||
| void | BeginCommentBlock () | ||||||
| After this function is invoked, all other data written will be a comment. | |||||||
| void | EndCommentBlock () | ||||||
| Ends a comment block. | |||||||
| void | InsertNewLine () | ||||||
| Inserts a blank line into the text. | |||||||
| void | WriteComment (const std::string &comment) | ||||||
| Writes a string of text and prepends it with a comment. This is equivalent to the `// comment` in C++. | |||||||
| void | WriteLine (const std::string &comment, bool new_line=true) | ||||||
| Writes an unaltered string to the file. | |||||||
Table Write Functions | |||||||
These functions write the beginning and ends of Lua tables
| |||||||
| void | BeginTable (int32 key) | ||||||
| void | BeginTable (const std::string &key) | ||||||
| void | EndTable () | ||||||
File Access Functions | |||||||
| |||||||
| void | CloseFile () | ||||||
| Closes the script file and sets the _access_mode member to SCRIPT_CLOSED. | |||||||
| bool | OpenFile () | ||||||
| Opens the file named by the classes' _filename member. | |||||||
| bool | OpenFile (const std::string &file_name) | ||||||
Variable Write Functions | |||||||
These functions will write a single variable and its value to a Lua file.
| |||||||
| void | WriteBool (const int32 key, bool value) | ||||||
| void | WriteBool (const std::string &key, bool value) | ||||||
| void | WriteFloat (const int32 key, float value) | ||||||
| void | WriteFloat (const std::string &key, float value) | ||||||
| void | WriteInt (const int32 key, int32 value) | ||||||
| void | WriteInt (const std::string &key, int32 value) | ||||||
| void | WriteString (const int32 key, const std::string &value) | ||||||
| void | WriteString (const std::string &key, const std::string &value) | ||||||
| void | WriteUInt (const int32 key, uint32 value) | ||||||
| void | WriteUInt (const std::string &key, uint32 value) | ||||||
| void | WriteUString (const int32 key, const std::string &value) | ||||||
| void | WriteUString (const std::string &key, const std::string &value) | ||||||
Vector Write Functions | |||||||
These functions write a vector of data to a Lua file.
| |||||||
| void | WriteBoolVector (const int32 key, std::vector< bool > &vect) | ||||||
| void | WriteBoolVector (const std::string &key, std::vector< bool > &vect) | ||||||
| void | WriteFloatVector (const int32 key, std::vector< float > &vect) | ||||||
| void | WriteFloatVector (const std::string &key, std::vector< float > &vect) | ||||||
| void | WriteIntVector (const int32 key, std::vector< int32 > &vect) | ||||||
| void | WriteIntVector (const std::string &key, std::vector< int32 > &vect) | ||||||
| void | WriteStringVector (const int32 key, std::vector< std::string > &vect) | ||||||
| void | WriteStringVector (const std::string &key, std::vector< std::string > &vect) | ||||||
| void | WriteUIntVector (const int32 key, std::vector< int32 > &vect) | ||||||
| void | WriteUIntVector (const std::string &key, std::vector< int32 > &vect) | ||||||
| void | WriteUStringVector (const int32 key, std::vector< std::string > &vect) | ||||||
| void | WriteUStringVector (const std::string &key, std::vector< std::string > &vect) | ||||||
Private Member Functions | |||||||
| void | _WriteTablePath () | ||||||
| Writes the pathname of all open tables (i.e., table1[table2][table3]). | |||||||
Variable Write Templates | |||||||
These template functions are called by the public WriteTYPE functions of this class.
| |||||||
| template<class T> | |||||||
| void | _WriteData (const int32 key, T value) | ||||||
| template<class T> | |||||||
| void | _WriteData (const std::string &key, T value) | ||||||
Vector Read Templates | |||||||
These template functions are called by the public ReadTYPEVector functions of this class.
| |||||||
| template<class T> | |||||||
| void | _WriteDataVector (const int32 key, std::vector< T > &vect) | ||||||
| template<class T> | |||||||
| void | _WriteDataVector (const std::string &key, std::vector< T > &vect) | ||||||
Private Attributes | |||||||
| bool | _inside_comment_block | ||||||
| Set to true after a comment block begins and false after the comment block ends. | |||||||
| std::ofstream | _outfile | ||||||
| The output file stream to write to for when the file is opened in write mode. | |||||||
Friends | |||||||
| class | GameScript | ||||||
****************************************************************************
This class does not actually involve Lua in any way. Rather, it provides an interface with which to write a Lua file from scratch. One area of the code base which uses this class graciously is the Allacrost editor when it saves new map files. Be cautious when using this class, as it can overwrite existing Lua files. This class is primarily for writing data, not code, although it is indeed possible to write script code using this class.
Except where noted in the function's comments, all methods automatically insert a new line into the file after they write their requested contents.
Definition at line 52 of file script_write.h.
| hoa_script::WriteScriptDescriptor::~WriteScriptDescriptor | ( | ) |
Definition at line 30 of file script_write.cpp.
References hoa_script::ScriptDescriptor::_access_mode, hoa_script::ScriptDescriptor::_error_messages, hoa_script::ScriptDescriptor::_filename, hoa_script::ScriptDescriptor::_open_tables, CloseFile(), hoa_script::ScriptDescriptor::IsFileOpen(), hoa_script::SCRIPT_CLOSED, and hoa_script::SCRIPT_DEBUG.
Here is the call graph for this function:

| void hoa_script::WriteScriptDescriptor::_WriteData | ( | const int32 | key, | |
| T | value | |||
| ) | [private] |
Definition at line 231 of file script_write.h.
References hoa_script::ScriptDescriptor::_error_messages, hoa_script::ScriptDescriptor::_open_tables, _outfile, and _WriteTablePath().
Here is the call graph for this function:

| void hoa_script::WriteScriptDescriptor::_WriteData | ( | const std::string & | key, | |
| T | value | |||
| ) | [private] |
Definition at line 220 of file script_write.h.
References hoa_script::ScriptDescriptor::_open_tables, _outfile, and _WriteTablePath().
Referenced by WriteFloat(), WriteInt(), and WriteUInt().
Here is the call graph for this function:

| void hoa_script::WriteScriptDescriptor::_WriteDataVector | ( | const int32 | key, | |
| std::vector< T > & | vect | |||
| ) | [private] |
Definition at line 268 of file script_write.h.
References hoa_script::ScriptDescriptor::_error_messages, hoa_script::ScriptDescriptor::_open_tables, _outfile, and _WriteTablePath().
Here is the call graph for this function:

| void hoa_script::WriteScriptDescriptor::_WriteDataVector | ( | const std::string & | key, | |
| std::vector< T > & | vect | |||
| ) | [private] |
Definition at line 244 of file script_write.h.
References hoa_script::ScriptDescriptor::_error_messages, hoa_script::ScriptDescriptor::_open_tables, _outfile, and _WriteTablePath().
Referenced by WriteFloatVector(), WriteIntVector(), and WriteUIntVector().
Here is the call graph for this function:

| void hoa_script::WriteScriptDescriptor::_WriteTablePath | ( | ) | [private] |
Writes the pathname of all open tables (i.e., table1[table2][table3]).
Definition at line 413 of file script_write.cpp.
References hoa_script::ScriptDescriptor::_error_messages, hoa_script::ScriptDescriptor::_open_tables, and _outfile.
Referenced by _WriteData(), _WriteDataVector(), BeginTable(), WriteBool(), and WriteBoolVector().
| void hoa_script::WriteScriptDescriptor::BeginCommentBlock | ( | ) |
After this function is invoked, all other data written will be a comment.
Definition at line 133 of file script_write.cpp.
References hoa_script::ScriptDescriptor::_error_messages, _inside_comment_block, and _outfile.
| void hoa_script::WriteScriptDescriptor::BeginTable | ( | int32 | key | ) |
Definition at line 386 of file script_write.cpp.
References hoa_script::ScriptDescriptor::_open_tables, _outfile, and _WriteTablePath().
Here is the call graph for this function:

| void hoa_script::WriteScriptDescriptor::BeginTable | ( | const std::string & | key | ) |
Referenced by hoa_script::ModifyScriptDescriptor::_CommitTable(), and hoa_editor::Grid::SaveMap().
| void hoa_script::WriteScriptDescriptor::CloseFile | ( | ) | [virtual] |
Closes the script file and sets the _access_mode member to SCRIPT_CLOSED.
Implements hoa_script::ScriptDescriptor.
Definition at line 96 of file script_write.cpp.
References hoa_script::ScriptDescriptor::_access_mode, hoa_script::ScriptDescriptor::_error_messages, hoa_script::ScriptDescriptor::_filename, hoa_script::ScriptDescriptor::_open_tables, _outfile, hoa_script::GameScript::_RemoveOpenFile(), hoa_script::ScriptDescriptor::IsErrorDetected(), hoa_script::ScriptDescriptor::IsFileOpen(), hoa_script::SCRIPT_CLOSED, hoa_script::SCRIPT_DEBUG, and hoa_script::ScriptManager.
Referenced by hoa_script::ModifyScriptDescriptor::CommitChanges(), hoa_editor::Grid::SaveMap(), and ~WriteScriptDescriptor().
Here is the call graph for this function:

| void hoa_script::WriteScriptDescriptor::EndCommentBlock | ( | ) |
Ends a comment block.
Definition at line 146 of file script_write.cpp.
References hoa_script::ScriptDescriptor::_error_messages, _inside_comment_block, and _outfile.
| void hoa_script::WriteScriptDescriptor::EndTable | ( | ) |
Definition at line 399 of file script_write.cpp.
References hoa_script::ScriptDescriptor::_error_messages, and hoa_script::ScriptDescriptor::_open_tables.
Referenced by hoa_script::ModifyScriptDescriptor::_CommitTable(), and hoa_editor::Grid::SaveMap().
| void hoa_script::WriteScriptDescriptor::InsertNewLine | ( | ) |
Inserts a blank line into the text.
Definition at line 121 of file script_write.cpp.
References _outfile.
Referenced by hoa_global::GameGlobal::_SaveCharacter(), hoa_global::GameGlobal::_SaveInventory(), and hoa_editor::Grid::SaveMap().
| bool hoa_script::WriteScriptDescriptor::OpenFile | ( | ) | [virtual] |
Opens the file named by the classes' _filename member.
Implements hoa_script::ScriptDescriptor.
Definition at line 83 of file script_write.cpp.
References hoa_script::ScriptDescriptor::_filename, and hoa_script::SCRIPT_DEBUG.
| bool hoa_script::WriteScriptDescriptor::OpenFile | ( | const std::string & | file_name | ) | [virtual] |
| file_name | The name of the Lua file to be opened. |
Implements hoa_script::ScriptDescriptor.
Referenced by hoa_script::ModifyScriptDescriptor::CommitChanges(), and hoa_editor::Grid::SaveMap().
| void hoa_script::WriteScriptDescriptor::WriteBool | ( | const int32 | key, | |
| bool | value | |||
| ) |
Definition at line 191 of file script_write.cpp.
References hoa_script::ScriptDescriptor::_error_messages, hoa_script::ScriptDescriptor::_open_tables, _outfile, and _WriteTablePath().
Here is the call graph for this function:

| void hoa_script::WriteScriptDescriptor::WriteBool | ( | const std::string & | key, | |
| bool | value | |||
| ) |
Referenced by hoa_script::ModifyScriptDescriptor::_CommitTable().
| void hoa_script::WriteScriptDescriptor::WriteBoolVector | ( | const int32 | key, | |
| std::vector< bool > & | vect | |||
| ) |
Definition at line 281 of file script_write.cpp.
References hoa_script::ScriptDescriptor::_error_messages, hoa_script::ScriptDescriptor::_open_tables, _outfile, and _WriteTablePath().
Here is the call graph for this function:

| void hoa_script::WriteScriptDescriptor::WriteBoolVector | ( | const std::string & | key, | |
| std::vector< bool > & | vect | |||
| ) |
| void hoa_script::WriteScriptDescriptor::WriteComment | ( | const std::string & | comment | ) |
Writes a string of text and prepends it with a comment. This is equivalent to the `// comment` in C++.
Referenced by hoa_editor::Grid::SaveMap().
| void hoa_script::WriteScriptDescriptor::WriteFloat | ( | const int32 | key, | |
| float | value | |||
| ) | [inline] |
Definition at line 122 of file script_write.h.
References _WriteData().
Here is the call graph for this function:

| void hoa_script::WriteScriptDescriptor::WriteFloat | ( | const std::string & | key, | |
| float | value | |||
| ) | [inline] |
Definition at line 119 of file script_write.h.
References _WriteData().
Referenced by hoa_script::ModifyScriptDescriptor::_CommitTable().
Here is the call graph for this function:

| void hoa_script::WriteScriptDescriptor::WriteFloatVector | ( | const int32 | key, | |
| std::vector< float > & | vect | |||
| ) | [inline] |
Definition at line 161 of file script_write.h.
References _WriteDataVector().
Here is the call graph for this function:

| void hoa_script::WriteScriptDescriptor::WriteFloatVector | ( | const std::string & | key, | |
| std::vector< float > & | vect | |||
| ) | [inline] |
Definition at line 158 of file script_write.h.
References _WriteDataVector().
Here is the call graph for this function:

Definition at line 110 of file script_write.h.
References _WriteData().
Here is the call graph for this function:

| void hoa_script::WriteScriptDescriptor::WriteInt | ( | const std::string & | key, | |
| int32 | value | |||
| ) | [inline] |
Definition at line 107 of file script_write.h.
References _WriteData().
Referenced by hoa_script::ModifyScriptDescriptor::_CommitTable(), and hoa_editor::Grid::SaveMap().
Here is the call graph for this function:

| void hoa_script::WriteScriptDescriptor::WriteIntVector | ( | const int32 | key, | |
| std::vector< int32 > & | vect | |||
| ) | [inline] |
Definition at line 149 of file script_write.h.
References _WriteDataVector().
Here is the call graph for this function:

| void hoa_script::WriteScriptDescriptor::WriteIntVector | ( | const std::string & | key, | |
| std::vector< int32 > & | vect | |||
| ) | [inline] |
Definition at line 146 of file script_write.h.
References _WriteDataVector().
Referenced by hoa_editor::Grid::SaveMap().
Here is the call graph for this function:

| void hoa_script::WriteScriptDescriptor::WriteLine | ( | const std::string & | comment, | |
| bool | new_line = true | |||
| ) |
Writes an unaltered string to the file.
| comment | The string of text to write to the file | |
| new_line | If true, automatically appends a new line (enabled by default) |
Referenced by hoa_global::GameGlobal::_SaveCharacter(), hoa_global::GameGlobal::_SaveEvents(), hoa_global::GameGlobal::_SaveInventory(), and hoa_editor::Grid::SaveMap().
| void hoa_script::WriteScriptDescriptor::WriteString | ( | const int32 | key, | |
| const std::string & | value | |||
| ) |
| void hoa_script::WriteScriptDescriptor::WriteString | ( | const std::string & | key, | |
| const std::string & | value | |||
| ) |
Referenced by hoa_script::ModifyScriptDescriptor::_CommitTable(), and hoa_editor::Grid::SaveMap().
| void hoa_script::WriteScriptDescriptor::WriteStringVector | ( | const int32 | key, | |
| std::vector< std::string > & | vect | |||
| ) |
| void hoa_script::WriteScriptDescriptor::WriteStringVector | ( | const std::string & | key, | |
| std::vector< std::string > & | vect | |||
| ) |
Definition at line 116 of file script_write.h.
References _WriteData().
Here is the call graph for this function:

| void hoa_script::WriteScriptDescriptor::WriteUInt | ( | const std::string & | key, | |
| uint32 | value | |||
| ) | [inline] |
Definition at line 113 of file script_write.h.
References _WriteData().
Here is the call graph for this function:

| void hoa_script::WriteScriptDescriptor::WriteUIntVector | ( | const int32 | key, | |
| std::vector< int32 > & | vect | |||
| ) | [inline] |
Definition at line 155 of file script_write.h.
References _WriteDataVector().
Here is the call graph for this function:

| void hoa_script::WriteScriptDescriptor::WriteUIntVector | ( | const std::string & | key, | |
| std::vector< int32 > & | vect | |||
| ) | [inline] |
Definition at line 152 of file script_write.h.
References _WriteDataVector().
Here is the call graph for this function:

| void hoa_script::WriteScriptDescriptor::WriteUString | ( | const int32 | key, | |
| const std::string & | value | |||
| ) |
| void hoa_script::WriteScriptDescriptor::WriteUString | ( | const std::string & | key, | |
| const std::string & | value | |||
| ) |
The WriteUString functions actually take standard strings, not ustrings, for their value. What these methods do is write the string to the Lua file with the gettext translation code attached so that when the value is retrieved, the appropriate string translation is returned from gettext instead of the actual base string contained in the file.
| void hoa_script::WriteScriptDescriptor::WriteUStringVector | ( | const int32 | key, | |
| std::vector< std::string > & | vect | |||
| ) |
| void hoa_script::WriteScriptDescriptor::WriteUStringVector | ( | const std::string & | key, | |
| std::vector< std::string > & | vect | |||
| ) |
friend class GameScript [friend] |
bool hoa_script::WriteScriptDescriptor::_inside_comment_block [private] |
Set to true after a comment block begins and false after the comment block ends.
Definition at line 188 of file script_write.h.
Referenced by BeginCommentBlock(), and EndCommentBlock().
std::ofstream hoa_script::WriteScriptDescriptor::_outfile [private] |
The output file stream to write to for when the file is opened in write mode.
Definition at line 185 of file script_write.h.
Referenced by _WriteData(), _WriteDataVector(), _WriteTablePath(), BeginCommentBlock(), BeginTable(), CloseFile(), EndCommentBlock(), InsertNewLine(), WriteBool(), and WriteBoolVector().
1.5.1