Subversion Repositories spk

Rev

Rev 82 | Rev 88 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 82 Rev 84
Line 57... Line 57...
57
	return "";	
57
	return "";	
58
}
58
}
59
 
59
 
60
Utils::String CTextDB::_parseText(int iLang, const Utils::String &sText, const Utils::String &sReplace) const
60
Utils::String CTextDB::_parseText(int iLang, const Utils::String &sText, const Utils::String &sReplace) const
61
{
61
{
62
	std::string::size_type pos = sReplace.find_first_of(",", 0);
62
	Utils::String::size_type pos = sReplace.find_first_of(",", 0);
63
	if ( pos != std::string::npos ) {
63
	if ( pos != Utils::String::npos ) {
64
		int iPage = Utils::String(sReplace.substr(1, pos));
64
		int iPage = Utils::String(sReplace.substr(1, pos));
65
		int iID = Utils::String(sReplace.substr(pos + 1, sReplace.length() - pos - 2));
65
		int iID = Utils::String(sReplace.substr(pos + 1, sReplace.length() - pos - 2));
66
		return sText.findReplace(sReplace, this->get(iLang, iPage, iID));
66
		return sText.findReplace(sReplace, this->get(iLang, iPage, iID));
67
	}
67
	}
68
 
68
 
Line 71... Line 71...
71
 
71
 
72
Utils::String CTextDB::_parseText(int iLang, const Utils::String &sText) const
72
Utils::String CTextDB::_parseText(int iLang, const Utils::String &sText) const
73
{
73
{
74
	Utils::String sNewText = sText;
74
	Utils::String sNewText = sText;
75
 
75
 
76
	std::string::size_type pos = sNewText.find_first_of("{", 0);
76
	Utils::String::size_type pos = sNewText.find_first_of("{", 0);
77
	while ( pos != std::string::npos ) {
77
	while ( pos != Utils::String::npos ) {
78
		std::string::size_type endPos = sNewText.find_first_of("}", pos);
78
		Utils::String::size_type endPos = sNewText.find_first_of("}", pos);
79
		if ( endPos != std::string::npos ) {
79
		if ( endPos != Utils::String::npos ) {
80
			sNewText = this->_parseText(iLang, sNewText, sNewText.substr(pos, (endPos - pos) + 1));
80
			sNewText = this->_parseText(iLang, sNewText, sNewText.substr(pos, (endPos - pos) + 1));
81
			pos = sNewText.find_first_of("{", 0);
81
			pos = sNewText.find_first_of("{", 0);
82
		}
82
		}
83
		else
83
		else
84
			pos = sNewText.find_first_of("{", pos);
84
			pos = sNewText.find_first_of("{", pos);
Line 89... Line 89...
89
void CTextDB::_parseFileLine(int iFromPage, int iToPage, int iLang, const Utils::String &sLine)
89
void CTextDB::_parseFileLine(int iFromPage, int iToPage, int iLang, const Utils::String &sLine)
90
{
90
{
91
	if ( m_iInPage ) {
91
	if ( m_iInPage ) {
92
		// check for end of page
92
		// check for end of page
93
		size_t pos = sLine.find("</page>");
93
		size_t pos = sLine.find("</page>");
94
		if ( pos != std::string::npos ) {
94
		if ( pos != Utils::String::npos ) {
95
			m_iInPage = 0;
95
			m_iInPage = 0;
96
		}
96
		}
97
		else {
97
		else {
98
			this->_parsePage(iLang, sLine);
98
			this->_parsePage(iLang, sLine);
99
		}
99
		}
100
	}
100
	}
101
	else {
101
	else {
102
		size_t pos = sLine.find("<page id=\"");
102
		size_t pos = sLine.find("<page id=\"");
103
		if ( pos != std::string::npos ) {
103
		if ( pos != Utils::String::npos ) {
104
			pos += 10; // move to the end of the search string (after ")
104
			pos += 10; // move to the end of the search string (after ")
105
			size_t endPos = sLine.find("\"", pos);
105
			size_t endPos = sLine.find("\"", pos);
106
			int iPageID = Utils::String(sLine.substr(pos, endPos - pos));
106
			int iPageID = Utils::String(sLine.substr(pos, endPos - pos));
107
			iPageID %= 10000; // make sure we remove the game id
107
			iPageID %= 10000; // make sure we remove the game id
108
			//TODO: mark the game id so we can overright if the game id is the same or higher
108
			//TODO: mark the game id so we can overright if the game id is the same or higher
Line 118... Line 118...
118
 
118
 
119
void CTextDB::_parsePage(int iLang, const Utils::String &sLine)
119
void CTextDB::_parsePage(int iLang, const Utils::String &sLine)
120
{
120
{
121
	// move to the id number
121
	// move to the id number
122
	size_t pos = sLine.find("<t id=\"");
122
	size_t pos = sLine.find("<t id=\"");
123
	if ( pos == std::string::npos ) return;
123
	if ( pos == Utils::String::npos ) return;
124
		
124
		
125
	pos += 7; // move past to the "
125
	pos += 7; // move past to the "
126
	size_t endPos = sLine.find("\"", pos);
126
	size_t endPos = sLine.find("\"", pos);
127
	if ( endPos == std::string::npos ) return;
127
	if ( endPos == Utils::String::npos ) return;
128
 
128
 
129
	// get the number to add
129
	// get the number to add
130
	int iID = Utils::String(sLine.substr(pos, endPos - pos));
130
	int iID = Utils::String(sLine.substr(pos, endPos - pos));
131
	
131
	
132
	// now find the text
132
	// now find the text
133
	pos = sLine.find(">", endPos);
133
	pos = sLine.find(">", endPos);
134
	if ( pos == std::string::npos ) return;
134
	if ( pos == Utils::String::npos ) return;
135
	++pos;
135
	++pos;
136
	endPos = sLine.find("</t>", pos);
136
	endPos = sLine.find("</t>", pos);
137
	if ( endPos == std::string::npos ) return;
137
	if ( endPos == Utils::String::npos ) return;
138
 
138
 
139
	this->_addText(iLang, iID, sLine.substr(pos, endPos - pos));
139
	this->_addText(iLang, iID, sLine.substr(pos, endPos - pos));
140
}
140
}
141
 
141
 
142
void CTextDB::_addText(int iLang, int iID, const Utils::String &sText)
142
void CTextDB::_addText(int iLang, int iID, const Utils::String &sText)