Add to_json and from_json script functions

This commit is contained in:
GenevensiS
2025-08-07 18:45:12 +02:00
committed by GitHub
parent 12eb39b5e2
commit dc348b4812
18 changed files with 748 additions and 142 deletions
+1 -1
View File
@@ -149,8 +149,8 @@ public:
IndexMap<Key,Value>& get(const String& name, const vector<Key>& init_with);
/// Clear the delayed index map
void clear();
private:
map<String, intrusive_ptr<DelayedIndexMapsData<Key,Value>>> data;
private:
friend class Reader;
friend class Writer;
friend class GetDefaultMember;
+3
View File
@@ -118,6 +118,9 @@ public:
inline Packaged* getPackage() const { return package; }
String addLocale(String);
/// Set the value that will be returned by the next getValue() call (may mess up the state of the reader)
inline void setValue(const String& value) { state = UNHANDLED; previous_value = value; };
private:
// --------------------------------------------------- : Data
+6
View File
@@ -16,6 +16,12 @@
using boost::tribool;
// ----------------------------------------------------------------------------- : Writer
Writer::Writer(OutputStream& output)
: indentation(0)
, output(output)
, stream(output, wxEOL_UNIX, wxMBConvUTF8())
{}
Writer::Writer(OutputStream& output, Version file_app_version)
: indentation(0)
+5 -4
View File
@@ -25,8 +25,9 @@ DECLARE_POINTER_TYPE(StyleSheet);
class Writer {
public:
/// Construct a writer that writes to the given output stream
Writer(OutputStream& output);
Writer(OutputStream& output, Version file_app_version);
/// Tell the reflection code we are not reading
static constexpr bool isReading = false;
static constexpr bool isWriting = true;
@@ -72,11 +73,11 @@ public:
// special behaviour
void handle(const GameP&);
void handle(const StyleSheetP&);
private:
// --------------------------------------------------- : Data
/// Indentation of the current block
int indentation;
private:
// --------------------------------------------------- : Data
/// Blocks opened to which nothing has been written
vector<const Char*> pending_opened;
+1
View File
@@ -76,6 +76,7 @@ String tr(const String&, const String& subcat, const String& key, DefaultLocaleF
#define _TITLE_(s) tr(LOCALE_CAT_TITLE, _(s))
/// A localized string for type names in scripts
#define _TYPE_(s) tr(LOCALE_CAT_TYPE, _(s))
#define _TYPE_V_(s) tr(LOCALE_CAT_TYPE, s )
/// A localized string for action names
#define _ACTION_(s) tr(LOCALE_CAT_ACTION, _(s))
/// A localized string for error messages