Automatic use of singular names -> even more use of REFLECT instead of REFLECT_N.

This also works better for GetMember, since the plural names (which make sense for scripts) are the default.

git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@16 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
twanvl
2006-10-11 22:58:55 +00:00
parent 9de743030e
commit 156d1f6632
8 changed files with 36 additions and 23 deletions
+8 -7
View File
@@ -9,7 +9,7 @@
// ----------------------------------------------------------------------------- : Includes
#include "../prec.hpp"
#include <util/prec.hpp>
#include <wx/txtstrm.h>
// ----------------------------------------------------------------------------- : Reader
@@ -47,11 +47,12 @@ class Reader {
exitBlock();
}
}
/// Reads a vector from the input stream
template <typename T>
void handle(const Char* name, vector<T>& vector);
/// Reads an object of type T from the input stream
template <typename T> void handle(T& object);
/// Reads a vector from the input stream
template <typename T> void handle(vector<T>& vector);
/// Reads a shared_ptr from the input stream
template <typename T> void handle(shared_ptr<T>& pointer);
/// Reads a map from the input stream
@@ -109,12 +110,12 @@ shared_ptr<T> read_new(Reader& reader) {
}
template <typename T>
void Reader::handle(vector<T>& vector) {
String vectorKey = key;
while (key == vectorKey) { // TODO : check indent
moveNext(); // skip key
void Reader::handle(const Char* name, vector<T>& vector) {
String vectorKey = singular_form(name);
while (enterBlock(vectorKey)) {
vector.resize(vector.size() + 1);
handle(vector.back());
exitBlock();
}
}
+10 -9
View File
@@ -34,6 +34,9 @@ class Writer {
handle(object);
exitBlock();
}
/// Write a vector to the output stream
template <typename T>
void handle(const Char* name, const vector<T>& vector);
/// Write a string to the output stream
void handle(const String& str);
@@ -41,8 +44,6 @@ class Writer {
/// Write an object of type T to the output stream
template <typename T> void handle(const T& object);
/// Write a vector to the output stream
template <typename T> void handle(const vector<T>& vector);
/// Write a shared_ptr to the output stream
template <typename T> void handle(const shared_ptr<T>& pointer);
/// Write a map to the output stream
@@ -78,13 +79,13 @@ class Writer {
// ----------------------------------------------------------------------------- : Container types
template <typename T>
void Writer::handle(const vector<T>& vector) {
/*String vectorKey = key;
while (key == vectorKey) { // TODO : check indent
moveNext(); // skip key
vector.resize(vector.size() + 1);
handle(vector.back());
}*/
void Writer::handle(const Char* name, const vector<T>& vec) {
String vectorKey = singular_form(name);
for (vector<T>::const_iterator it = vec.begin() ; it != vec.end() ; ++it) {
enterBlock(vectorKey);
handle(*it);
exitBlock();
}
}
template <typename T>