bool TeSQLite::insertLegend(TeLegendEntry *legend) { errorMessage_ = ""; string sql = "INSERT INTO te_legend (theme_id, group_id, num_objs, lower_value, upper_value, "; sql += "label) VALUES("; sql += Te2String(legend->theme()); sql += ", "; sql += Te2String(legend->group()); sql += ", "; sql += Te2String(legend->count()); sql += ", '"; sql += escapeSequence(legend->from()); sql += "', '"; sql += escapeSequence(legend->to()); sql += "', '"; sql += escapeSequence(legend->label()); sql += "')"; if(this->execute(sql)) { //int newId = getMaxValue(this, "te_legend", "legend_id"); int newId = getLastInsertedSerial(); if(newId >= 0) { legend->id(newId); } } else return false; legendMap()[legend->id()] = legend; return insertVisual(legend); }
bool TeSQLite::insertPoint(const string& table, TePoint &p) { std::string q = "INSERT INTO " + table + "(object_id, x, y)"; q += " VALUES("; q += "'" + escapeSequence(p.objectId()) + "',"; q += Te2String(p.location().x_) + ","; q += Te2String(p.location().y_) + ")"; if(execute(q) == false) { return false; } //int newId = getMaxValue(this, table, "geom_id"); int newId = getLastInsertedSerial(); if(newId >= 0) { p.geomId(newId); } return true; }
Token Lexer::stringLiteral(int delimiter) { StringBuilder s(compiler); int c; // The common case here is that the string contains unproblematic ASCII characters. // // OPTIMIZEME: for the common case we should not need to accumulate data in a StringBuilder, // we should be able to go straight to a Str, as for the identifier case. (Probably // less critical here though.) for (;;) { const wchar* start = idx; // OPTIMIZEME: too many conditions in this test now. Should bias for ASCII // and use table lookup to test for delimiters, NUL, and line endings. while ((c = *idx) != delimiter && c != '\\' && c != 0 && c != '\n' && c != '\r' && c != UNICHAR_LS && c != UNICHAR_PS && c != UNICHAR_BOM1 && c != UNICHAR_BOM2) idx++; s.append(start, idx); switch (*idx) { case '\'': case '"': if (*idx == delimiter) { idx++; val.s = s.str(); DEBUG_ONLY(last_token = T_StringLiteral); return T_StringLiteral; } break; // syntax error case '\\': idx++; switch (*idx) { case '\r': idx++; if (*idx == '\n') idx++; lineno++; continue; case UNICHAR_LS: case UNICHAR_PS: case '\n': idx++; lineno++; continue; default: s.append(escapeSequence()); continue; } case UNICHAR_BOM1: case UNICHAR_BOM2: s.append(' '); idx++; continue; case 0: if (idx < limit) { s.append(0); idx++; continue; } break; // syntax error } compiler->syntaxError(lineno, "Unterminated string literal"); } }
bool TeSQLite::insertTheme(TeAbstractTheme *theme) { errorMessage_ = ""; string sql = "INSERT INTO te_theme (layer_id, view_id, name, parent_id, priority, node_type, "; sql += "min_scale, max_scale, generate_attribute_where, generate_spatial_where, "; sql += "generate_temporal_where, collection_table, visible_rep, enable_visibility, "; sql += "lower_x, lower_y, upper_x, upper_y, creation_time) VALUES("; if(theme->type()==TeTHEME) sql += Te2String(static_cast<TeTheme*>(theme)->layerId()); else sql += " NULL "; sql += ", "; sql += Te2String(theme->view()); sql += ", '"; sql += theme->name(); sql += "', "; sql += Te2String(theme->parentId()); sql += ", "; sql += Te2String(theme->priority()); sql += ", "; sql += Te2String(theme->type()); sql += ", "; sql += Te2String(theme->minScale(), 15); sql += ", "; sql += Te2String(theme->maxScale(), 15); sql += ", '"; sql += escapeSequence(theme->attributeRest()); sql += "', '"; sql += escapeSequence(theme->spatialRest()); sql += "', '"; sql += escapeSequence(theme->temporalRest()); sql += "', '"; if(theme->type()==TeTHEME) sql += static_cast<TeTheme*>(theme)->collectionTable(); sql += "', "; sql += Te2String(theme->visibleRep()); sql += ", "; sql += Te2String(theme->visibility()); sql += ", "; sql += Te2String(theme->box().x1(), 15); sql += ", "; sql += Te2String(theme->box().y1(), 15); sql += ", "; sql += Te2String(theme->box().x2(), 15); sql += ", "; sql += Te2String(theme->box().y2(), 15); sql += ", "; TeTime creationTime = theme->getCreationTime(); sql += getSQLTime(creationTime); sql += " )"; if(this->execute(sql)) { //int newId = getMaxValue(this, "te_theme", "theme_id"); int newId = getLastInsertedSerial(); if(newId >= 0) { theme->id(newId); } } else return false; if((theme->type()==TeTHEME || theme->type()==TeEXTERNALTHEME) && static_cast<TeTheme*>(theme)->collectionTable().empty()) { sql = "UPDATE te_theme SET"; sql += " collection_table = 'te_collection_" + Te2String(theme->id()) + "'"; sql += " WHERE theme_id = "; sql += Te2String(theme->id()); static_cast<TeTheme*>(theme)->collectionTable(string("te_collection_") + Te2String(theme->id())); if(!this->execute(sql)) return false; } if(theme->parentId() == 0) { std::string sql = "UPDATE te_theme SET"; sql += " parent_id = " + Te2String(theme->id()); sql += " WHERE theme_id = "; sql += Te2String(theme->id()); theme->parentId(theme->id()); if(!this->execute(sql)) return false; } bool status; // insert grouping int numSlices = 0; if(theme->grouping().groupMode_ != TeNoGrouping) { if(!insertGrouping (theme->id(), theme->grouping())) return false; numSlices = theme->grouping().groupNumSlices_; } // insert legend theme->outOfCollectionLegend().group(-1); theme->outOfCollectionLegend().theme(theme->id()); status = insertLegend (&(theme->outOfCollectionLegend())); if (!status) return status; theme->withoutDataConnectionLegend().group(-2); theme->withoutDataConnectionLegend().theme(theme->id()); status = insertLegend (&(theme->withoutDataConnectionLegend())); if (!status) return status; theme->defaultLegend().group(-3); theme->defaultLegend().theme(theme->id()); status = insertLegend (&(theme->defaultLegend())); if (!status) return status; theme->pointingLegend().group(-4); theme->pointingLegend().theme(theme->id()); status = insertLegend (&(theme->pointingLegend())); if (!status) return status; theme->queryLegend().group(-5); theme->queryLegend().theme(theme->id()); status = insertLegend (&(theme->queryLegend())); if (!status) return status; theme->queryAndPointingLegend().group(-6); theme->queryAndPointingLegend().theme(theme->id()); status = insertLegend (&(theme->queryAndPointingLegend())); if (!status) return status; for (int i = 0; i < numSlices; i++) { theme->legend()[i].group(i); theme->legend()[i].theme(theme->id()); status = insertLegend (&(theme->legend()[i])); if (!status) return status; } if (!status) return status; //insert metadata theme if(!theme->saveMetadata(this)) return false; themeMap()[theme->id()] = theme; if(theme->type()==TeTHEME && !updateThemeTable(static_cast<TeTheme*>(theme))) return false; return true; }