summaryrefslogtreecommitdiff
path: root/wii/stringtablebuilder.cpp
blob: 679247c7361d26c95efb25d5f77b6f1603fd3dc3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include "stringtablebuilder.h"

WiiStringTableBuilder::WiiStringTableBuilder() {
	m_nextOffset = 0;
	m_data = "";
}

quint32 WiiStringTableBuilder::add(QString str) {
	if (m_lookup.contains(str))
		return m_lookup.value(str);

	quint32 added = m_nextOffset;
	m_lookup.insert(str, added);

	m_data.append(str.toAscii());
	m_data.append('\0');

	m_nextOffset = m_data.length();

	return added;
}

QByteArray WiiStringTableBuilder::pack() {
	return m_data;
}