Subversion Repositories spk

Rev

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

Rev 88 Rev 94
Line 6... Line 6...
6
 
6
 
7
CTextDB::CTextDB(void)
7
CTextDB::CTextDB(void)
8
{
8
{
9
	m_iLang = 44;
9
	m_iLang = 44;
10
	m_pTexts = new TextList;
10
	m_pTexts = new TextList;
-
 
11
	m_pTextComment = new TextList;
11
	m_iInPage = 0;
12
	m_iInPage = 0;
12
}
13
}
13
 
14
 
14
CTextDB::~CTextDB(void)
15
CTextDB::~CTextDB(void)
15
{
16
{
16
	if ( m_pTexts ) delete m_pTexts;
17
	if ( m_pTexts ) delete m_pTexts;
-
 
18
	if ( m_pTextComment ) delete m_pTextComment;
17
}
19
}
18
 
20
 
19
void CTextDB::parseTextFile(int iFromPage, int iToPage, const Utils::String &sFile, int iLang)
21
void CTextDB::parseTextFile(int iFromPage, int iToPage, const Utils::String &sFile, int iLang)
20
{
22
{
21
	// open and read the text file
23
	// open and read the text file
Line 139... Line 141...
139
	this->_addText(iLang, iID, sLine.substr(pos, endPos - pos));
141
	this->_addText(iLang, iID, sLine.substr(pos, endPos - pos));
140
}
142
}
141
 
143
 
142
void CTextDB::_addText(int iLang, int iID, const Utils::String &sText)
144
void CTextDB::_addText(int iLang, int iID, const Utils::String &sText)
143
{
145
{
-
 
146
	// split the comment out
-
 
147
	Utils::String fullComment;
-
 
148
	Utils::String text = sText;
-
 
149
 
-
 
150
	while ( text.isin("(") && text.isin(")") ) {
-
 
151
		int iStart = text.findPos("(");
-
 
152
		if ( iStart != -1 ) {
-
 
153
			int iEnd = text.findPos(")", iStart);
-
 
154
			if ( iEnd != -1 ) {
-
 
155
				Utils::String comment = text.mid(iStart, ++iEnd);
-
 
156
				text.erase(iStart, iEnd - iStart);
-
 
157
				if ( !fullComment.empty() ) fullComment += ", ";
-
 
158
				fullComment += comment;
-
 
159
			}
-
 
160
		}
-
 
161
	}
-
 
162
 
-
 
163
	text.removeEndSpace();
-
 
164
 
144
	(*m_pTexts)[_mapID(iLang, m_iInPage, iID)] = sText;
165
	(*m_pTexts)[_mapID(iLang, m_iInPage, iID)] = text;
-
 
166
	if ( !fullComment.empty() )
-
 
167
		(*m_pTextComment)[_mapID(iLang, m_iInPage, iID)] = fullComment;
145
}
168
}
146
 
169
 
147
Utils::String CTextDB::_mapID(int iLang, int iPage, int iID) const
170
Utils::String CTextDB::_mapID(int iLang, int iPage, int iID) const
148
{
171
{
149
	Utils::String sID;
172
	Utils::String sID;