- aligned coding style in sqlite plugin
This commit is contained in:
parent
f1460b78cd
commit
c0273234b6
5 changed files with 178 additions and 192 deletions
|
@ -2,7 +2,7 @@
|
||||||
*
|
*
|
||||||
* This file is part of Mapnik (c++ mapping toolkit)
|
* This file is part of Mapnik (c++ mapping toolkit)
|
||||||
*
|
*
|
||||||
* Copyright (C) 2010 Artem Pavlenko
|
* Copyright (C) 2011 Artem Pavlenko
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -19,7 +19,6 @@
|
||||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
// $Id$
|
|
||||||
|
|
||||||
#include "sqlite_datasource.hpp"
|
#include "sqlite_datasource.hpp"
|
||||||
#include "sqlite_featureset.hpp"
|
#include "sqlite_featureset.hpp"
|
||||||
|
@ -27,9 +26,7 @@
|
||||||
// mapnik
|
// mapnik
|
||||||
#include <mapnik/ptree_helpers.hpp>
|
#include <mapnik/ptree_helpers.hpp>
|
||||||
#include <mapnik/sql_utils.hpp>
|
#include <mapnik/sql_utils.hpp>
|
||||||
|
#include <mapnik/feature_factory.hpp> // to enable extent fallback hack
|
||||||
// to enable extent fallback hack
|
|
||||||
#include <mapnik/feature_factory.hpp>
|
|
||||||
|
|
||||||
// boost
|
// boost
|
||||||
#include <boost/algorithm/string.hpp>
|
#include <boost/algorithm/string.hpp>
|
||||||
|
@ -39,15 +36,9 @@
|
||||||
#include <boost/filesystem/operations.hpp>
|
#include <boost/filesystem/operations.hpp>
|
||||||
#include <boost/make_shared.hpp>
|
#include <boost/make_shared.hpp>
|
||||||
|
|
||||||
|
|
||||||
using boost::lexical_cast;
|
using boost::lexical_cast;
|
||||||
using boost::bad_lexical_cast;
|
using boost::bad_lexical_cast;
|
||||||
|
|
||||||
using mapnik::datasource;
|
|
||||||
using mapnik::parameters;
|
|
||||||
|
|
||||||
DATASOURCE_PLUGIN(sqlite_datasource)
|
|
||||||
|
|
||||||
using mapnik::box2d;
|
using mapnik::box2d;
|
||||||
using mapnik::coord2d;
|
using mapnik::coord2d;
|
||||||
using mapnik::query;
|
using mapnik::query;
|
||||||
|
@ -55,7 +46,10 @@ using mapnik::featureset_ptr;
|
||||||
using mapnik::layer_descriptor;
|
using mapnik::layer_descriptor;
|
||||||
using mapnik::attribute_descriptor;
|
using mapnik::attribute_descriptor;
|
||||||
using mapnik::datasource_exception;
|
using mapnik::datasource_exception;
|
||||||
|
using mapnik::datasource;
|
||||||
|
using mapnik::parameters;
|
||||||
|
|
||||||
|
DATASOURCE_PLUGIN(sqlite_datasource)
|
||||||
|
|
||||||
sqlite_datasource::sqlite_datasource(parameters const& params, bool bind)
|
sqlite_datasource::sqlite_datasource(parameters const& params, bool bind)
|
||||||
: datasource(params),
|
: datasource(params),
|
||||||
|
@ -258,8 +252,10 @@ void sqlite_datasource::bind() const
|
||||||
{
|
{
|
||||||
// TODO - we can't trust so much the rowid here
|
// TODO - we can't trust so much the rowid here
|
||||||
if (key_field_ == "rowid")
|
if (key_field_ == "rowid")
|
||||||
|
{
|
||||||
desc_.add_descriptor(attribute_descriptor("rowid", mapnik::Integer));
|
desc_.add_descriptor(attribute_descriptor("rowid", mapnik::Integer));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (use_pragma_table_info)
|
if (use_pragma_table_info)
|
||||||
{
|
{
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
*
|
*
|
||||||
* This file is part of Mapnik (c++ mapping toolkit)
|
* This file is part of Mapnik (c++ mapping toolkit)
|
||||||
*
|
*
|
||||||
* Copyright (C) 2007 Artem Pavlenko
|
* Copyright (C) 2011 Artem Pavlenko
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -19,7 +19,6 @@
|
||||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
//$Id$
|
|
||||||
|
|
||||||
#ifndef SQLITE_DATASOURCE_HPP
|
#ifndef SQLITE_DATASOURCE_HPP
|
||||||
#define SQLITE_DATASOURCE_HPP
|
#define SQLITE_DATASOURCE_HPP
|
||||||
|
@ -38,8 +37,6 @@
|
||||||
#include "sqlite_types.hpp"
|
#include "sqlite_types.hpp"
|
||||||
|
|
||||||
|
|
||||||
//==============================================================================
|
|
||||||
|
|
||||||
class sqlite_datasource : public mapnik::datasource
|
class sqlite_datasource : public mapnik::datasource
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -52,6 +49,7 @@ class sqlite_datasource : public mapnik::datasource
|
||||||
mapnik::box2d<double> envelope() const;
|
mapnik::box2d<double> envelope() const;
|
||||||
mapnik::layer_descriptor get_descriptor() const;
|
mapnik::layer_descriptor get_descriptor() const;
|
||||||
void bind() const;
|
void bind() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
mutable mapnik::box2d<double> extent_;
|
mutable mapnik::box2d<double> extent_;
|
||||||
mutable bool extent_initialized_;
|
mutable bool extent_initialized_;
|
||||||
|
@ -80,5 +78,4 @@ class sqlite_datasource : public mapnik::datasource
|
||||||
void parse_attachdb(std::string const& attachdb) const;
|
void parse_attachdb(std::string const& attachdb) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif // SQLITE_DATASOURCE_HPP
|
#endif // SQLITE_DATASOURCE_HPP
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
*
|
*
|
||||||
* This file is part of Mapnik (c++ mapping toolkit)
|
* This file is part of Mapnik (c++ mapping toolkit)
|
||||||
*
|
*
|
||||||
* Copyright (C) 2007 Artem Pavlenko
|
* Copyright (C) 2011 Artem Pavlenko
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -19,7 +19,6 @@
|
||||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
//$Id$
|
|
||||||
|
|
||||||
// mapnik
|
// mapnik
|
||||||
#include <mapnik/global.hpp>
|
#include <mapnik/global.hpp>
|
||||||
|
@ -57,7 +56,9 @@ sqlite_featureset::sqlite_featureset(boost::shared_ptr<sqlite_resultset> rs,
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
sqlite_featureset::~sqlite_featureset() {}
|
sqlite_featureset::~sqlite_featureset()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
feature_ptr sqlite_featureset::next()
|
feature_ptr sqlite_featureset::next()
|
||||||
{
|
{
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
*
|
*
|
||||||
* This file is part of Mapnik (c++ mapping toolkit)
|
* This file is part of Mapnik (c++ mapping toolkit)
|
||||||
*
|
*
|
||||||
* Copyright (C) 2007 Artem Pavlenko
|
* Copyright (C) 2011 Artem Pavlenko
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -19,7 +19,6 @@
|
||||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
//$Id$
|
|
||||||
|
|
||||||
#ifndef SQLITE_FEATURESET_HPP
|
#ifndef SQLITE_FEATURESET_HPP
|
||||||
#define SQLITE_FEATURESET_HPP
|
#define SQLITE_FEATURESET_HPP
|
||||||
|
@ -37,8 +36,6 @@
|
||||||
#include "sqlite_types.hpp"
|
#include "sqlite_types.hpp"
|
||||||
|
|
||||||
|
|
||||||
//==============================================================================
|
|
||||||
|
|
||||||
class sqlite_featureset : public mapnik::Featureset
|
class sqlite_featureset : public mapnik::Featureset
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -49,6 +46,7 @@ class sqlite_featureset : public mapnik::Featureset
|
||||||
bool using_subquery);
|
bool using_subquery);
|
||||||
virtual ~sqlite_featureset();
|
virtual ~sqlite_featureset();
|
||||||
mapnik::feature_ptr next();
|
mapnik::feature_ptr next();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
boost::shared_ptr<sqlite_resultset> rs_;
|
boost::shared_ptr<sqlite_resultset> rs_;
|
||||||
boost::scoped_ptr<mapnik::transcoder> tr_;
|
boost::scoped_ptr<mapnik::transcoder> tr_;
|
||||||
|
@ -57,5 +55,4 @@ class sqlite_featureset : public mapnik::Featureset
|
||||||
bool using_subquery_;
|
bool using_subquery_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif // SQLITE_FEATURESET_HPP
|
#endif // SQLITE_FEATURESET_HPP
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
*
|
*
|
||||||
* This file is part of Mapnik (c++ mapping toolkit)
|
* This file is part of Mapnik (c++ mapping toolkit)
|
||||||
*
|
*
|
||||||
* Copyright (C) 2007 Artem Pavlenko
|
* Copyright (C) 2011 Artem Pavlenko
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -19,13 +19,12 @@
|
||||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
//$Id$
|
|
||||||
|
|
||||||
#ifndef SQLITE_TYPES_HPP
|
#ifndef SQLITE_TYPES_HPP
|
||||||
#define SQLITE_TYPES_HPP
|
#define SQLITE_TYPES_HPP
|
||||||
|
|
||||||
// stdc++
|
// stl
|
||||||
#include <string.h>
|
#include <cstring>
|
||||||
|
|
||||||
// mapnik
|
// mapnik
|
||||||
#include <mapnik/datasource.hpp>
|
#include <mapnik/datasource.hpp>
|
||||||
|
@ -40,32 +39,25 @@ extern "C" {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//==============================================================================
|
|
||||||
|
|
||||||
class sqlite_utils
|
class sqlite_utils
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
static void dequote(std::string& z)
|
static void dequote(std::string& z)
|
||||||
{
|
{
|
||||||
boost::algorithm::trim_if(z, boost::algorithm::is_any_of("[]'\"`"));
|
boost::algorithm::trim_if(z, boost::algorithm::is_any_of("[]'\"`"));
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
//==============================================================================
|
|
||||||
|
|
||||||
class sqlite_resultset
|
class sqlite_resultset
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
sqlite_resultset(sqlite3_stmt* stmt)
|
sqlite_resultset(sqlite3_stmt* stmt)
|
||||||
: stmt_(stmt)
|
: stmt_(stmt)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
~sqlite_resultset ()
|
virtual ~sqlite_resultset()
|
||||||
{
|
{
|
||||||
if (stmt_)
|
if (stmt_)
|
||||||
{
|
{
|
||||||
|
@ -160,8 +152,6 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
//==============================================================================
|
|
||||||
|
|
||||||
class sqlite_connection
|
class sqlite_connection
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -204,10 +194,16 @@ public:
|
||||||
{
|
{
|
||||||
std::ostringstream s;
|
std::ostringstream s;
|
||||||
s << "Sqlite Plugin: ";
|
s << "Sqlite Plugin: ";
|
||||||
|
|
||||||
if (db_)
|
if (db_)
|
||||||
|
{
|
||||||
s << "'" << sqlite3_errmsg(db_) << "'";
|
s << "'" << sqlite3_errmsg(db_) << "'";
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
s << "unknown error, lost connection";
|
s << "unknown error, lost connection";
|
||||||
|
}
|
||||||
|
|
||||||
s << "\nFull sql was: '" << sql << "'\n";
|
s << "\nFull sql was: '" << sql << "'\n";
|
||||||
|
|
||||||
throw mapnik::datasource_exception (s.str());
|
throw mapnik::datasource_exception (s.str());
|
||||||
|
@ -251,5 +247,4 @@ private:
|
||||||
sqlite3* db_;
|
sqlite3* db_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif // SQLITE_TYPES_HPP
|
#endif // SQLITE_TYPES_HPP
|
||||||
|
|
Loading…
Reference in a new issue