Wed, 08 Feb 2017 16:25:06 +0200
Switched from euler angle rotation to matrix rotation. Gimbal lock is now broken.
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1 | /* |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
2 | * LDForge: LDraw parts authoring CAD |
1072 | 3 | * Copyright (C) 2013 - 2017 Teemu Piippo |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
4 | * |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
5 | * This program is free software: you can redistribute it and/or modify |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
6 | * it under the terms of the GNU General Public License as published by |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
7 | * the Free Software Foundation, either version 3 of the License, or |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
8 | * (at your option) any later version. |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
9 | * |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
10 | * This program is distributed in the hope that it will be useful, |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
13 | * GNU General Public License for more details. |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
14 | * |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
15 | * You should have received a copy of the GNU General Public License |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
17 | */ |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
18 | |
946 | 19 | #include <QFile> |
998 | 20 | #include <QMessageBox> |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
21 | #include "colors.h" |
1012 | 22 | #include "ldpaths.h" |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
23 | |
998 | 24 | static ColorData* colorData = nullptr; |
946 | 25 | |
1044 | 26 | /* |
27 | * initColors | |
28 | * | |
29 | * Initializes the color information module. | |
30 | */ | |
998 | 31 | void initColors() |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
32 | { |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
33 | print ("Initializing color information.\n"); |
998 | 34 | static ColorData colors; |
35 | colorData = &colors; | |
946 | 36 | } |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
37 | |
1044 | 38 | /* |
39 | * LDColor :: LDColor | |
40 | * | |
41 | * Default-constructs an LDColor to 0 (black). | |
42 | */ | |
43 | LDColor::LDColor() : | |
44 | m_index (0) {} | |
45 | ||
46 | /* | |
47 | * LDColor :: LDColor | |
48 | * | |
49 | * Constructs an LDColor by index. | |
50 | */ | |
51 | LDColor::LDColor (qint32 index) | |
52 | : m_index (index) {} | |
53 | ||
54 | /* | |
55 | * LDColor :: isValid | |
56 | * | |
57 | * Returns whether or not the color is valid. | |
58 | */ | |
946 | 59 | bool LDColor::isValid() const |
60 | { | |
998 | 61 | if (isLDConfigColor() and data().name.isEmpty()) |
946 | 62 | return false; // Unknown LDConfig color |
1044 | 63 | else |
64 | return m_index != -1; | |
795
195fa1fff9c3
- changed all color usage to use LDColor classes instead of color indices. Added support for direct colors.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
706
diff
changeset
|
65 | } |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
66 | |
1044 | 67 | /* |
68 | * LDColor :: isLDConfigColor | |
69 | * | |
70 | * Returns whether or not this color is defined in LDConfig.ldr. | |
71 | * This is false for e.g. direct colors. | |
72 | */ | |
946 | 73 | bool LDColor::isLDConfigColor() const |
795
195fa1fff9c3
- changed all color usage to use LDColor classes instead of color indices. Added support for direct colors.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
706
diff
changeset
|
74 | { |
1044 | 75 | return colorData->contains(index()); |
998 | 76 | } |
77 | ||
1044 | 78 | /* |
79 | * LDColor :: data | |
80 | * | |
81 | * Returns the ColorData entry for this color. | |
82 | */ | |
998 | 83 | const ColorData::Entry& LDColor::data() const |
84 | { | |
1044 | 85 | return colorData->get(index()); |
795
195fa1fff9c3
- changed all color usage to use LDColor classes instead of color indices. Added support for direct colors.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
706
diff
changeset
|
86 | } |
195fa1fff9c3
- changed all color usage to use LDColor classes instead of color indices. Added support for direct colors.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
706
diff
changeset
|
87 | |
1044 | 88 | /* |
89 | * LDColor :: name | |
90 | * | |
91 | * Returns the name of this color. | |
92 | */ | |
946 | 93 | QString LDColor::name() const |
795
195fa1fff9c3
- changed all color usage to use LDColor classes instead of color indices. Added support for direct colors.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
706
diff
changeset
|
94 | { |
946 | 95 | if (isDirect()) |
96 | return "0x" + QString::number (index(), 16).toUpper(); | |
97 | else if (isLDConfigColor()) | |
998 | 98 | return data().name; |
946 | 99 | else if (index() == -1) |
100 | return "null color"; | |
101 | else | |
1044 | 102 | return "unknown"; |
946 | 103 | } |
104 | ||
1044 | 105 | /* |
106 | * LDColor :: hexcode | |
107 | * | |
108 | * Returns the hexadecimal code of this color. | |
109 | */ | |
946 | 110 | QString LDColor::hexcode() const |
111 | { | |
112 | return faceColor().name(); | |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
113 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
114 | |
1044 | 115 | /* |
116 | * LDColor :: faceColor | |
117 | * | |
118 | * Returns the color used for surfaces. | |
119 | */ | |
946 | 120 | QColor LDColor::faceColor() const |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
121 | { |
946 | 122 | if (isDirect()) |
123 | { | |
1044 | 124 | // Direct color -- compute from the index. |
946 | 125 | QColor color; |
1044 | 126 | color.setRed((index() & 0x0FF0000) >> 16); |
127 | color.setGreen((index() & 0x000FF00) >> 8); | |
128 | color.setBlue(index() & 0x00000FF); | |
946 | 129 | |
130 | if (index() >= 0x3000000) | |
1044 | 131 | color.setAlpha(128); |
946 | 132 | |
133 | return color; | |
134 | } | |
135 | else if (isLDConfigColor()) | |
136 | { | |
998 | 137 | return data().faceColor; |
946 | 138 | } |
139 | else | |
140 | { | |
141 | return Qt::black; | |
142 | } | |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
143 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
144 | |
1044 | 145 | /* |
146 | * LDColor :: edgeColor | |
147 | * | |
148 | * Returns the color used for edge lines. | |
149 | */ | |
946 | 150 | QColor LDColor::edgeColor() const |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
151 | { |
946 | 152 | if (isDirect()) |
1044 | 153 | return luma(faceColor()) < 48 ? Qt::white : Qt::black; |
946 | 154 | else if (isLDConfigColor()) |
998 | 155 | return data().edgeColor; |
946 | 156 | else |
157 | return Qt::black; | |
158 | } | |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
159 | |
1044 | 160 | /* |
161 | * LDColor :: index | |
162 | * | |
163 | * Returns the index number of this color. | |
164 | */ | |
946 | 165 | qint32 LDColor::index() const |
166 | { | |
167 | return m_index; | |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
168 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
169 | |
1044 | 170 | /* |
171 | * LDColor :: indexString | |
172 | * | |
173 | * Returns a string containing the preferred representation of the index. | |
174 | */ | |
806
4240f47aa2d4
- moved most of LDColorData API into LDColor
Santeri Piippo <crimsondusk64@gmail.com>
parents:
797
diff
changeset
|
175 | QString LDColor::indexString() const |
4240f47aa2d4
- moved most of LDColorData API into LDColor
Santeri Piippo <crimsondusk64@gmail.com>
parents:
797
diff
changeset
|
176 | { |
4240f47aa2d4
- moved most of LDColorData API into LDColor
Santeri Piippo <crimsondusk64@gmail.com>
parents:
797
diff
changeset
|
177 | if (isDirect()) |
1044 | 178 | { |
179 | // Use hexadecimal notation for direct colors. | |
180 | return "0x" + QString::number(index(), 16).toUpper(); | |
181 | } | |
182 | else | |
183 | { | |
184 | return QString::number(index()); | |
185 | } | |
806
4240f47aa2d4
- moved most of LDColorData API into LDColor
Santeri Piippo <crimsondusk64@gmail.com>
parents:
797
diff
changeset
|
186 | } |
4240f47aa2d4
- moved most of LDColorData API into LDColor
Santeri Piippo <crimsondusk64@gmail.com>
parents:
797
diff
changeset
|
187 | |
1044 | 188 | /* |
189 | * LDColor :: isDirect | |
190 | * | |
191 | * Returns whether or not this color is a direct color. | |
192 | * Direct colors are picked by RGB value and are not defined in LDConfig.ldr. | |
193 | */ | |
806
4240f47aa2d4
- moved most of LDColorData API into LDColor
Santeri Piippo <crimsondusk64@gmail.com>
parents:
797
diff
changeset
|
194 | bool LDColor::isDirect() const |
4240f47aa2d4
- moved most of LDColorData API into LDColor
Santeri Piippo <crimsondusk64@gmail.com>
parents:
797
diff
changeset
|
195 | { |
4240f47aa2d4
- moved most of LDColorData API into LDColor
Santeri Piippo <crimsondusk64@gmail.com>
parents:
797
diff
changeset
|
196 | return index() >= 0x02000000; |
4240f47aa2d4
- moved most of LDColorData API into LDColor
Santeri Piippo <crimsondusk64@gmail.com>
parents:
797
diff
changeset
|
197 | } |
4240f47aa2d4
- moved most of LDColorData API into LDColor
Santeri Piippo <crimsondusk64@gmail.com>
parents:
797
diff
changeset
|
198 | |
1044 | 199 | /* |
200 | * LDColor :: nullColor | |
201 | * | |
202 | * Returns a color that is guaranteed to be invalid. | |
203 | */ | |
204 | LDColor LDColor::nullColor() | |
205 | { | |
206 | return LDColor {-1}; | |
207 | } | |
208 | ||
209 | /* | |
210 | * qHash | |
211 | * | |
212 | * LDColors are hashed by their index. | |
213 | */ | |
1031
55c0d3beea0d
removed removeDuplicates in favor of QSet, and the unused ObjectList class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1014
diff
changeset
|
214 | uint qHash(LDColor color) |
55c0d3beea0d
removed removeDuplicates in favor of QSet, and the unused ObjectList class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1014
diff
changeset
|
215 | { |
55c0d3beea0d
removed removeDuplicates in favor of QSet, and the unused ObjectList class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1014
diff
changeset
|
216 | return color.index(); |
55c0d3beea0d
removed removeDuplicates in favor of QSet, and the unused ObjectList class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1014
diff
changeset
|
217 | } |
55c0d3beea0d
removed removeDuplicates in favor of QSet, and the unused ObjectList class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1014
diff
changeset
|
218 | |
1044 | 219 | /* |
220 | * luma | |
221 | * | |
222 | * Calculates the luma-value for the given color. | |
223 | * c.f. https://en.wikipedia.org/wiki/Luma_(video) | |
224 | */ | |
225 | int luma (const QColor& color) | |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
226 | { |
1044 | 227 | return round((0.2126 * color.red()) + (0.7152 * color.green()) + (0.0722 * color.blue())); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
228 | } |
795
195fa1fff9c3
- changed all color usage to use LDColor classes instead of color indices. Added support for direct colors.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
706
diff
changeset
|
229 | |
1044 | 230 | /* |
231 | * ColorData :: ColorData | |
232 | * | |
233 | * Constructs the color data array. | |
234 | */ | |
998 | 235 | ColorData::ColorData() |
795
195fa1fff9c3
- changed all color usage to use LDColor classes instead of color indices. Added support for direct colors.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
706
diff
changeset
|
236 | { |
998 | 237 | if (colorData == nullptr) |
238 | colorData = this; | |
239 | ||
240 | // Initialize main and edge colors, they're special like that. | |
1044 | 241 | m_data[MainColor].faceColor = "#AAAAAA"; |
998 | 242 | m_data[MainColor].edgeColor = Qt::black; |
243 | m_data[MainColor].name = "Main color"; | |
244 | m_data[EdgeColor].faceColor = | |
1044 | 245 | m_data[EdgeColor].edgeColor = "#000000"; |
998 | 246 | m_data[EdgeColor].name = "Edge color"; |
1044 | 247 | |
248 | // Load the rest from LDConfig.ldr. | |
998 | 249 | loadFromLdconfig(); |
250 | } | |
251 | ||
1044 | 252 | /* |
253 | * ColorData :: ~ColorData | |
254 | * | |
255 | * Cleanup the colorData pointer after the array is deleted. | |
256 | */ | |
998 | 257 | ColorData::~ColorData() |
258 | { | |
259 | if (colorData == this) | |
260 | colorData = nullptr; | |
795
195fa1fff9c3
- changed all color usage to use LDColor classes instead of color indices. Added support for direct colors.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
706
diff
changeset
|
261 | } |
946 | 262 | |
1044 | 263 | /* |
264 | * ColorData :: contains | |
265 | * | |
266 | * Returns whether or not the given color index is present in the array. | |
267 | */ | |
268 | bool ColorData::contains(int code) const | |
946 | 269 | { |
1065
c8ecddbd99e9
Actually, let's call it countof(). Makes more sense.
Teemu Piippo <teemu@hecknology.net>
parents:
1063
diff
changeset
|
270 | return code >= 0 and code < countof(m_data); |
998 | 271 | } |
272 | ||
1044 | 273 | /* |
274 | * ColorData :: get | |
275 | * | |
276 | * Returns an entry in the color array. | |
277 | */ | |
278 | const ColorData::Entry& ColorData::get(int code) const | |
998 | 279 | { |
1044 | 280 | if (not contains(code)) |
281 | throw std::runtime_error {"Attempted to get non-existant color information"}; | |
946 | 282 | |
998 | 283 | return m_data[code]; |
284 | } | |
285 | ||
1044 | 286 | /* |
287 | * ColorData :: loadFromLdconfig | |
288 | * | |
289 | * Loads color information from LDConfig.ldr. | |
290 | */ | |
998 | 291 | void ColorData::loadFromLdconfig() |
292 | { | |
1012 | 293 | QString path = LDPaths::ldConfigPath(); |
1044 | 294 | QFile file {path}; |
998 | 295 | |
1044 | 296 | if (not file.open (QIODevice::ReadOnly)) |
946 | 297 | { |
1044 | 298 | QMessageBox::critical(nullptr, "Error", "Unable to open LDConfig.ldr for parsing: " + file.errorString()); |
946 | 299 | return; |
300 | } | |
301 | ||
998 | 302 | // TODO: maybe LDConfig can be loaded as a Document? Or would that be overkill? |
1044 | 303 | while (not file.atEnd()) |
946 | 304 | { |
1044 | 305 | QString line = QString::fromUtf8 (file.readLine()); |
946 | 306 | |
307 | if (line.isEmpty() or line[0] != '0') | |
308 | continue; // empty or illogical | |
309 | ||
1044 | 310 | line.remove('\r'); |
311 | line.remove('\n'); | |
946 | 312 | |
313 | // Parse the line | |
1044 | 314 | LDConfigParser parser = {line}; |
998 | 315 | QString name; |
316 | QString facename; | |
317 | QString edgename; | |
318 | QString codestring; | |
946 | 319 | |
320 | // Check 0 !COLOUR, parse the name | |
1044 | 321 | if (not parser.compareToken(0, "0") or not parser.compareToken(1, "!COLOUR") or not parser.getToken(name, 2)) |
946 | 322 | continue; |
323 | ||
324 | // Replace underscores in the name with spaces for readability | |
1044 | 325 | name.replace("_", " "); |
946 | 326 | |
998 | 327 | if (not parser.parseTag ("CODE", codestring)) |
946 | 328 | continue; |
329 | ||
330 | bool ok; | |
1044 | 331 | int code = codestring.toShort(&ok); |
946 | 332 | |
1044 | 333 | if (not ok or not contains(code)) |
946 | 334 | continue; |
335 | ||
1044 | 336 | if (not parser.parseTag("VALUE", facename) or not parser.parseTag("EDGE", edgename)) |
946 | 337 | continue; |
338 | ||
339 | // Ensure that our colors are correct | |
1044 | 340 | QColor faceColor = {facename}; |
341 | QColor edgeColor = {edgename}; | |
946 | 342 | |
343 | if (not faceColor.isValid() or not edgeColor.isValid()) | |
344 | continue; | |
345 | ||
1044 | 346 | // Fill in the entry now. |
998 | 347 | Entry& entry = m_data[code]; |
946 | 348 | entry.name = name; |
349 | entry.faceColor = faceColor; | |
350 | entry.edgeColor = edgeColor; | |
998 | 351 | |
1044 | 352 | // If the alpha tag is present, fill in that too. |
353 | if (parser.parseTag("ALPHA", codestring)) | |
354 | entry.faceColor.setAlpha(qBound(0, codestring.toInt(), 255)); | |
946 | 355 | } |
356 | } | |
357 | ||
1044 | 358 | /* |
359 | * LDConfigParser :: LDConfigParser | |
360 | * | |
361 | * Constructs the LDConfig.ldr parser. | |
362 | */ | |
363 | LDConfigParser::LDConfigParser(QString inputText) | |
946 | 364 | { |
1044 | 365 | m_tokens = inputText.split (' ', QString::SkipEmptyParts); |
946 | 366 | } |
367 | ||
1044 | 368 | /* |
369 | * LDConfigParser :: getToken | |
370 | * | |
371 | * Returns whether or not there is a token at the given position. | |
372 | * If there is, fills in the value parameter with it. | |
373 | */ | |
374 | bool LDConfigParser::getToken(QString& tokenText, int position) | |
946 | 375 | { |
1065
c8ecddbd99e9
Actually, let's call it countof(). Makes more sense.
Teemu Piippo <teemu@hecknology.net>
parents:
1063
diff
changeset
|
376 | if (position >= countof(m_tokens)) |
1044 | 377 | { |
946 | 378 | return false; |
1044 | 379 | } |
380 | else | |
381 | { | |
382 | tokenText = m_tokens[position]; | |
383 | return true; | |
384 | } | |
946 | 385 | } |
386 | ||
1044 | 387 | /* |
388 | * LDConfigParser :: findToken | |
389 | * | |
390 | * Attempts to find the provided token in the parsed LDConfig.ldr line. | |
391 | * If found, fills in the first parameter with the position of the token. | |
392 | * | |
393 | * The args parameter specifies how many arguments (i.e. following tokens) the token needs to have. | |
394 | */ | |
395 | bool LDConfigParser::findToken(int& tokenPosition, QString needle, int args) | |
946 | 396 | { |
1065
c8ecddbd99e9
Actually, let's call it countof(). Makes more sense.
Teemu Piippo <teemu@hecknology.net>
parents:
1063
diff
changeset
|
397 | for (int i = 0; i < (countof(m_tokens) - args); ++i) |
946 | 398 | { |
399 | if (m_tokens[i] == needle) | |
400 | { | |
1044 | 401 | tokenPosition = i; |
946 | 402 | return true; |
403 | } | |
404 | } | |
405 | ||
406 | return false; | |
407 | } | |
408 | ||
1044 | 409 | /* |
410 | * LDConfigParser :: compareToken | |
411 | * | |
412 | * Returns whether or not the token at the given position has the given text value. | |
413 | */ | |
414 | bool LDConfigParser::compareToken (int position, QString text) | |
946 | 415 | { |
1044 | 416 | QString token; |
946 | 417 | |
1044 | 418 | if (not getToken(token, position)) |
946 | 419 | return false; |
1044 | 420 | else |
421 | return (token == text); | |
946 | 422 | } |
423 | ||
1044 | 424 | /* |
425 | * LDConfig :: parseTag | |
426 | * | |
427 | * Finds an attribute in the line, and fills in its value. | |
428 | * For instance, if the line contains "ALPHA 128", this function can find the "128" for "ALPHA". | |
429 | * Returns whether or not the attribute was found. | |
430 | */ | |
431 | bool LDConfigParser::parseTag (QString key, QString& value) | |
946 | 432 | { |
1044 | 433 | int position; |
946 | 434 | |
435 | // Try find the token and get its position | |
1044 | 436 | if (not findToken (position, key, 1)) |
437 | { | |
946 | 438 | return false; |
1044 | 439 | } |
440 | else | |
441 | { | |
442 | // Get the token after it and store it in. | |
443 | return getToken (value, position + 1); | |
444 | } | |
445 | } |