Support string-list properties in the cache.
Not used yet, but will aid in caching joystick and dialog configs.
This commit is contained in:
parent
c9351e0185
commit
32248bf576
2 changed files with 35 additions and 1 deletions
|
@ -422,6 +422,9 @@ public:
|
||||||
|
|
||||||
void prepareQueries()
|
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 POSITIONED_COLS "rowid, type, ident, name, airport, lon, lat, elev_m, octree_node"
|
||||||
#define AND_TYPED "AND type>=?2 AND type <=?3"
|
#define AND_TYPED "AND type>=?2 AND type <=?3"
|
||||||
statCacheCheck = prepare("SELECT stamp FROM stat_cache WHERE path=?");
|
statCacheCheck = prepare("SELECT stamp FROM stat_cache WHERE path=?");
|
||||||
|
@ -748,6 +751,7 @@ public:
|
||||||
stampFileCache, statCacheCheck,
|
stampFileCache, statCacheCheck,
|
||||||
loadAirportStmt, loadCommStation, loadPositioned, loadNavaid,
|
loadAirportStmt, loadCommStation, loadPositioned, loadNavaid,
|
||||||
loadRunwayStmt;
|
loadRunwayStmt;
|
||||||
|
sqlite3_stmt_ptr writePropertyMulti, clearProperty;
|
||||||
|
|
||||||
sqlite3_stmt_ptr insertPositionedQuery, insertAirport, insertTower, insertRunway,
|
sqlite3_stmt_ptr insertPositionedQuery, insertAirport, insertTower, insertRunway,
|
||||||
insertCommStation, insertNavaid;
|
insertCommStation, insertNavaid;
|
||||||
|
@ -1054,7 +1058,32 @@ void NavDataCache::writeDoubleProperty(const string& key, const double& value)
|
||||||
d->execSelect(d->writePropertyQuery);
|
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
|
bool NavDataCache::isCachedFileModified(const SGPath& path) const
|
||||||
{
|
{
|
||||||
if (!path.exists()) {
|
if (!path.exists()) {
|
||||||
|
|
|
@ -25,6 +25,8 @@
|
||||||
#define FG_NAVDATACACHE_HXX
|
#define FG_NAVDATACACHE_HXX
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
|
#include <simgear/misc/strutils.hxx> // for string_list
|
||||||
#include <Navaids/positioned.hxx>
|
#include <Navaids/positioned.hxx>
|
||||||
|
|
||||||
class SGPath;
|
class SGPath;
|
||||||
|
@ -78,6 +80,9 @@ public:
|
||||||
void writeStringProperty(const std::string& key, const std::string& value);
|
void writeStringProperty(const std::string& key, const std::string& value);
|
||||||
void writeDoubleProperty(const std::string& key, const double& 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);
|
FGPositioned* loadById(PositionedID guid);
|
||||||
|
|
||||||
PositionedID insertAirport(FGPositioned::Type ty, const std::string& ident,
|
PositionedID insertAirport(FGPositioned::Type ty, const std::string& ident,
|
||||||
|
|
Loading…
Add table
Reference in a new issue