src/ldconfig.h

changeset 667
31540c1f22ea
parent 606
3dd6f343ec06
equal deleted inserted replaced
666:c595cfb4791c 667:31540c1f22ea
1 /* 1 /*
2 * LDForge: LDraw parts authoring CAD 2 * LDForge: LDraw parts authoring CAD
3 * Copyright (C) 2013 Santeri Piippo 3 * Copyright (C) 2013, 2014 Santeri Piippo
4 * 4 *
5 * This program is free software: you can redistribute it and/or modify 5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by 6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or 7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version. 8 * (at your option) any later version.
14 * 14 *
15 * You should have received a copy of the GNU General Public License 15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>. 16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */ 17 */
18 18
19 #ifndef LDCONFIG_H 19 #ifndef LDFORGE_LDCONFIG_H
20 #define LDCONFIG_H 20 #define LDFORGE_LDCONFIG_H
21 21
22 #include "types.h" 22 #include "types.h"
23 #include <QStringList> 23 #include <QStringList>
24 24
25 // ============================================================================= 25 // =============================================================================
26 // StringParser 26 // LDConfigParser
27 // 27 //
28 // String parsing utility 28 // String parsing utility for parsing ldconfig.ldr
29 // ============================================================================= 29 // =============================================================================
30 class LDConfigParser 30 class LDConfigParser
31 { public: 31 {
32 LDConfigParser (str inText, char sep); 32 public:
33 LDConfigParser (QString inText, char sep);
33 34
34 bool atEnd(); 35 bool isAtEnd();
35 bool atBeginning(); 36 bool isAtBeginning();
36 bool next (str& val); 37 bool getNextToken (QString& val);
37 bool peekNext (str& val); 38 bool peekNextToken (QString& val);
38 bool getToken (str& val, const int pos); 39 bool getToken (QString& val, const int pos);
39 bool findToken (short& result, char const* needle, short args); 40 bool findToken (int& result, char const* needle, int args);
40 size_t size(); 41 int getSize();
41 void rewind(); 42 void rewind();
42 void seek (short amount, bool rel); 43 void seek (int amount, bool rel);
43 bool tokenCompare (short inPos, const char* sOther); 44 bool tokenCompare (int inPos, const char* sOther);
44 45
45 str operator[] (const size_t idx) 46 inline QString operator[] (const int idx)
46 { return m_tokens[idx]; 47 {
48 return m_tokens[idx];
47 } 49 }
48 50
49 private: 51 private:
50 QStringList m_tokens; 52 QStringList m_tokens;
51 int m_pos; 53 int m_pos;
52 }; 54 };
53 55
54 void parseLDConfig(); 56 void parseLDConfig();
55 57
56 #endif // LDCONFIG_H 58 #endif // LDFORGE_LDCONFIG_H

mercurial