void dump_data(std::ostream& out, DBCStorage<T> const& store, bool ext_insert = true) { std::string class_name = ClassInfo<T>::name; strip_trailing(class_name, "Entry"); if (ext_insert) out << "INSERT INTO " << class_name << " VALUES\n"; uint32 last_row = store.GetNumRows() - 1; for (uint32 row = 0; row <= last_row; ++row) { T const* entry = store.LookupEntry(row); if (!entry) continue; if (ext_insert) out << "("; else out << "INSERT INTO " << class_name << " VALUES ("; uint32 col = 0; for (FieldList::const_iterator itr = ClassInfo<T>::fields.begin(); itr != ClassInfo<T>::fields.end(); ++itr, ++col) { bool is_text = ((*itr)->getType() == TYPE_STRING || (*itr)->getType()== TYPE_STRING_CONST) && (*itr)->isArray() && (*itr)->getArraySize() == 16; // all string fields have 16 locales if (is_text && (*itr)->getArrayIndex() != 0) // only dump en_US locale continue; if (col > 0) out << ", "; if (is_text) out << '\'' << escape_string((*itr)->getValue(const_cast<T*>(entry))) << '\''; else out << (*itr)->getValue(const_cast<T*>(entry)); } if (ext_insert) out << (row < last_row ? "),\n" : ");\n"); else out << ");\n"; } }