void prepareQueries()
{
+ clearProperty = prepare("DELETE FROM properties WHERE key=?1");
+ writePropertyMulti = prepare("INSERT INTO properties (key, value) VALUES(?,?)");
+
#define POSITIONED_COLS "rowid, type, ident, name, airport, lon, lat, elev_m, octree_node"
#define AND_TYPED "AND type>=?2 AND type <=?3"
statCacheCheck = prepare("SELECT stamp FROM stat_cache WHERE path=?");
stampFileCache, statCacheCheck,
loadAirportStmt, loadCommStation, loadPositioned, loadNavaid,
loadRunwayStmt;
+ sqlite3_stmt_ptr writePropertyMulti, clearProperty;
sqlite3_stmt_ptr insertPositionedQuery, insertAirport, insertTower, insertRunway,
insertCommStation, insertNavaid;
d->execSelect(d->writePropertyQuery);
}
-
+string_list NavDataCache::readStringListProperty(const string& key)
+{
+ d->reset(d->readPropertyQuery);
+ sqlite_bind_stdstring(d->readPropertyQuery, 1, key);
+ string_list result;
+ while (d->stepSelect(d->readPropertyQuery)) {
+ result.push_back((char*) sqlite3_column_text(d->readPropertyQuery, 1));
+ }
+
+ return result;
+}
+
+void NavDataCache::writeStringListProperty(const string& key, const string_list& values)
+{
+ d->reset(d->clearProperty);
+ sqlite_bind_stdstring(d->clearProperty, 1, key);
+ d->execUpdate(d->clearProperty);
+
+ sqlite_bind_stdstring(d->writePropertyMulti, 1, key);
+ BOOST_FOREACH(string value, values) {
+ d->reset(d->writePropertyMulti);
+ sqlite_bind_stdstring(d->writePropertyMulti, 2, value);
+ d->execInsert(d->writePropertyMulti);
+ }
+}
+
bool NavDataCache::isCachedFileModified(const SGPath& path) const
{
if (!path.exists()) {
#define FG_NAVDATACACHE_HXX
#include <memory>
+
+#include <simgear/misc/strutils.hxx> // for string_list
#include <Navaids/positioned.hxx>
class SGPath;
void writeStringProperty(const std::string& key, const std::string& value);
void writeDoubleProperty(const std::string& key, const double& value);
+ string_list readStringListProperty(const std::string& key);
+ void writeStringListProperty(const std::string& key, const string_list& values);
+
FGPositioned* loadById(PositionedID guid);
PositionedID insertAirport(FGPositioned::Type ty, const std::string& ident,