+ map<int, TypeDescription>::const_iterator i(typeDescriptions.find(id));
+ if (i != typeDescriptions.end()) {
+ return i->second;
+ } else {
+ std::stringstream msg;
+ msg << "invalid type ID " << id;
+ throw invalid_argument(msg.str());
+ }
+}
+
+
+int TypeDescription::GetMaxSize() {
+ int max = 0;
+ for (map<int, TypeDescription>::const_iterator
+ i(typeDescriptions.begin()),
+ end(typeDescriptions.end());
+ i != end; ++i) {
+ if (i->second.Size() > max) {
+ max = i->second.Size();
+ }
+ }
+ return max;
+}
+
+
+void TypeDescription::WriteSourceWiki(std::ostream &out) {
+ vector<string> types;
+ for (map<int, TypeDescription>::const_iterator i(typeDescriptions.begin()), end(typeDescriptions.end()); i != end; ++i) {
+ if (i->second.name != "Animation") {
+ types.push_back(i->second.name);
+ }
+ }
+ std::sort(types.begin(), types.end());
+
+ out << "h2. Data types" << endl << endl;
+
+ for (vector<string>::const_iterator i(types.begin()), end(types.end()); i != end; ++i) {
+ out << "* [[LoaderSource#" << *i << "|" << *i << "]]" << endl;
+ }
+ out << endl << endl;
+
+ for (vector<string>::const_iterator i(types.begin()), end(types.end()); i != end; ++i) {
+ const TypeDescription &td(Get(GetTypeId(*i)));
+ out << "h3. " << td.TypeName() << endl << endl;
+
+ out << "Type ID: @" << td.TypeId() << "@" << endl << endl;
+
+ if (td.Description()) {
+ out << td.Description() << endl << endl;
+ }
+
+ if (td.FieldsBegin() == td.FieldsEnd()) {
+ out << "No properties." << endl << endl;
+ } else {
+ out << "| *Property* | *Type* | *Description* |" << endl;
+ for (FieldIterator field(td.FieldsBegin()); field != td.FieldsEnd(); ++field) {
+ const FieldDescription &fd(field->second);
+ out << "| " << field->first << " | ";
+ if (fd.IsAggregate()) {
+ out << "Array<" << Get(fd.TypeId()).TypeName() << ">";
+ } else {
+ out << Get(fd.TypeId()).TypeName();
+ }
+ out << " | ";
+ if (fd.Description()) {
+ out << fd.Description();
+ }
+ out << " |" << endl;
+ }
+ out << endl;
+ }
+ }