bool EmoticonsManager::loadGGEmoticonThemePart(const QString &themeSubDirPath) { QString dir = themeSubDirPath; if (!dir.isEmpty() && !dir.endsWith('/')) dir += '/'; QFile theme_file(dir + "emots.txt"); if (!theme_file.open(QIODevice::ReadOnly)) { kdebugm(KDEBUG_FUNCTION_END|KDEBUG_WARNING, "Error opening %s file\n", qPrintable(theme_file.fileName())); return false; } QTextStream theme_stream(&theme_file); theme_stream.setCodec(codec_cp1250); while (!theme_stream.atEnd()) { EmoticonsListItem item; QString line = theme_stream.readLine(); kdebugm(KDEBUG_DUMP, "> %s\n", qPrintable(line)); unsigned int lineLength = line.length(); unsigned int i = 0; bool multi = false; QStringList aliases; if (i < lineLength && line.at(i) == '*') ++i; // eat '*' if (i < lineLength && line.at(i) == '(') { multi = true; ++i; } for (;;) { aliases.append(getQuoted(line, i)); if (!multi || i >= lineLength || line.at(i) == ')') break; ++i; // eat ',' } if (multi) ++i; // eat ')' ++i; // eat ',' item.anim = themeSubDirPath + '/' + fixFileName(themeSubDirPath, getQuoted(line, i)); if (i < lineLength && line.at(i) == ',') { ++i; // eat ',' item.stat = themeSubDirPath + '/' + fixFileName(themeSubDirPath, getQuoted(line, i)); } else item.stat = item.anim; foreach (const QString &alias, aliases) { item.alias = alias; Aliases.push_back(item); } item.alias = aliases.at(0); Selector.append(item); }
// no obj includes in as5; they come back in as6 bool SceneLoader::doInclude(istream &str, string& name) { if (!getName(str, "include", name)) return false; SceneGroup *n = new SceneGroup(); groups[name] = n; n->_name = name; string file = getQuoted(str); n->_mesh = new OBJTriangleMesh(file); do { int state = findOpenOrClosedParen(str); if (state == ERROR) { if (n->_meshMaterial == NULL) { n->_meshMaterial = new ParametricMaterial(); SetMaterialDefaults(n->_meshMaterial); } return false; } else if (state == CLOSED) { if (n->_meshMaterial == NULL) { n->_meshMaterial = new ParametricMaterial(); SetMaterialDefaults(n->_meshMaterial); } return true; } else if (state == OPEN) { string cmd; if (readCommand(str, cmd)) { if (cmd == "material") { string matName = getString(str); if (matName.empty()) { *err << "No material name after material command at "; errLine(str.tellg()); } else if (materials[matName] == NULL) { *err << "Unknown material " << matName << " referenced at "; errLine(str.tellg()); } else { n->_meshMaterial = materials[matName]; } } else { *err << "Error: command " << cmd << " not recognized at "; errLine(str.tellg()); } findCloseParen(str); } } } while (true); }
bool SceneLoader::doSurface(istream &str, string& name) { name = getString(str); if (name.empty()) { *err << "Couldn't read surface name at "; errLine(str.tellg()); return false; } if (_savedColors[name] != NULL) { *err << "Illegal re-use of surface name \"" << name << "\" at "; curPos(*err,str.tellg()); *err << endl; return false; } do { int state = findOpenOrClosedParen(str); if (state == ERROR) return false; else if (state == CLOSED) return true; else if (state == OPEN) { string cmd; vector<ParametricValue*> values; if (readCommand(str, cmd)) { if (cmd == "rgb") { int numv = getValues(str, values); if (numv < 3) { *err << "rgb with not enough args at "; errLine(str.tellg()); } else { cleanAfter(values, 3); Color *c = new Color(); for (int i = 0; i < 3; i++) { c->_color[i] = values[i]; } _savedColors[name] = c; } } else if (cmd == "bitmap") { // something with loading textures string file = getQuoted(str); _savedTextures[name] = file; } findCloseParen(str); } } } while (true); }
bool SceneLoader::doInclude(istream &str, string& name) { name = getString(str); if (name.empty()) { *err << "Couldn't read include name at "; errLine(str.tellg()); return false; } if (groups[name] != NULL) { *err << "Illegal re-use of variable name \"" << name << "\" at "; curPos(*err,str.tellg()); *err << endl; return false; } string file = getQuoted(str); SceneGroup *n = new SceneGroup(); n->_poly = new Polygon(file); n->_name = name; groups[name] = n; return true; }
/*------------------------------------------------------------Tokenizer::next-+ | | +----------------------------------------------------------------------------*/ Token Tokenizer::next(ReservedKeywords rsvd) { m_lenToken = -1; m_isBlankBefore = m_isBlankFound; m_isBlankFound = false; m_isCommentFound = false; m_startPos = (int)m_in.pubseekoff(0, ios::cur, ios::in) - 1; if ((rsvd != RSVD_NONE) && isalpha(m_cur)) { int c = m_cur; char * pCur = m_tokenBuf; for (;;) { *pCur++ = (c >= 'a')? c + 'A'-'a' : c; c = m_in.sgetc(); // peek if (!isalpha(c)) break; c = m_in.sbumpc(); // ok, read } m_lenToken = pCur - m_tokenBuf; if (!isSymbol(c)) { // keywords are fully alpha symbols int count; KeywordId const * ids; switch (rsvd) { case RSVD_WITHIN_DO: count = sizeof keywordsInDo / sizeof keywordsInDo[0]; ids = keywordsInDo; break; case RSVD_WITHIN_IF: count = sizeof keywordsInIf / sizeof keywordsInIf[0]; ids = keywordsInIf; break; case RSVD_WITHIN_PARSE: count = sizeof keywordsInParse / sizeof keywordsInParse[0]; ids = keywordsInParse; break; default: count = 0; break; } for (; count--; ++ids) { if (termEquals(*ids)) { nextChar(); return (Token)(*ids + TK_KEYWORD); } } } m_cur = m_tokenBuf[--m_lenToken]; // restart at last known alpha return getSymbol(); } switch (m_cur) { case '\n': ++m_lineno; /* fall thru */ case ';': nextChar(); return TK_SEMICOLON; case '+': nextChar(); return TK_PLUS; case '-': nextChar(); return TK_MINUS; case '%': nextChar(); return TK_IDIV; case '(': nextChar(); return TK_LEFTPAR; case ')': nextChar(); return TK_RIGHTPAR; case ',': nextChar(); return TK_COMMA; case ':': m_erh << ECE__ERROR << _REX__20_0 << endm; break; case '\'': case '\"': return getQuoted(); case '.': if (isSymbol(m_in.sgetc())) return getSymbol(); nextChar(); return TK_DOT; case '|': if (nextChar() == '|') { nextChar(); return TK_CONCAT; } return TK_OR; case '&': if (nextChar() == '&') { nextChar(); return TK_XOR; } return TK_AND; case '/': switch (nextChar()) { case '/': nextChar(); return TK_MOD; case '=': m_erh << ECE__ERROR << _REX__35_0 << endm; break; } return TK_DIV; case '*': switch (nextChar()) { case '*': nextChar(); return TK_POWER; case '/': m_erh << ECE__ERROR << _REX__35_0 << endm; break; } return TK_MUL; case '=': switch (nextChar()) { case '=': nextChar(); return TK_STRICT_EQ; case '>': case '<': m_erh << ECE__ERROR << _REX__35_0 << endm; break; } return TK_NORMAL_EQ; case '<': switch (nextChar()) { case '<': if (nextChar() == '=') { nextChar(); return TK_STRICT_LE; } return TK_STRICT_LT; case '=': nextChar(); return TK_NORMAL_LE; case '>': nextChar(); return TK_NORMAL_NE; } return TK_NORMAL_LT; case '>': switch (nextChar()) { case '>': if (nextChar() == '=') { nextChar(); return TK_STRICT_GE; } return TK_STRICT_GT; case '=': nextChar(); return TK_NORMAL_GE; case '<': nextChar(); return TK_NORMAL_NE; } return TK_NORMAL_GT; case '^': case '\\': switch (nextChar()) { case '=': if (nextChar() == '=') { nextChar(); return TK_STRICT_NE; } return TK_NORMAL_NE; case '>': if (nextChar() == '>') { nextChar(); return TK_STRICT_LE; } return TK_NORMAL_LE; case '<': if (nextChar() == '<') { nextChar(); return TK_STRICT_GE; } return TK_NORMAL_GE; } return TK_NOT; case -1: // EOF m_startPos = 1 + m_startPos; // b/c EOF is not 'real' // and b/c gcc doesn't like operator++ or operator+ !!! return TK_EOF; default: if (isSymbol(m_cur)) { return getSymbol(); } m_erh << ECE__ERROR << _REX__13_0 << endm; break; } assert (false); // never hit! return TK_EOF; }