- 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)
|
||||
*
|
||||
* Copyright (C) 2010 Artem Pavlenko
|
||||
* Copyright (C) 2011 Artem Pavlenko
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* 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
|
||||
*
|
||||
*****************************************************************************/
|
||||
// $Id$
|
||||
|
||||
#include "sqlite_datasource.hpp"
|
||||
#include "sqlite_featureset.hpp"
|
||||
|
@ -27,9 +26,7 @@
|
|||
// mapnik
|
||||
#include <mapnik/ptree_helpers.hpp>
|
||||
#include <mapnik/sql_utils.hpp>
|
||||
|
||||
// to enable extent fallback hack
|
||||
#include <mapnik/feature_factory.hpp>
|
||||
#include <mapnik/feature_factory.hpp> // to enable extent fallback hack
|
||||
|
||||
// boost
|
||||
#include <boost/algorithm/string.hpp>
|
||||
|
@ -39,15 +36,9 @@
|
|||
#include <boost/filesystem/operations.hpp>
|
||||
#include <boost/make_shared.hpp>
|
||||
|
||||
|
||||
using boost::lexical_cast;
|
||||
using boost::bad_lexical_cast;
|
||||
|
||||
using mapnik::datasource;
|
||||
using mapnik::parameters;
|
||||
|
||||
DATASOURCE_PLUGIN(sqlite_datasource)
|
||||
|
||||
using mapnik::box2d;
|
||||
using mapnik::coord2d;
|
||||
using mapnik::query;
|
||||
|
@ -55,7 +46,10 @@ using mapnik::featureset_ptr;
|
|||
using mapnik::layer_descriptor;
|
||||
using mapnik::attribute_descriptor;
|
||||
using mapnik::datasource_exception;
|
||||
using mapnik::datasource;
|
||||
using mapnik::parameters;
|
||||
|
||||
DATASOURCE_PLUGIN(sqlite_datasource)
|
||||
|
||||
sqlite_datasource::sqlite_datasource(parameters const& params, bool bind)
|
||||
: datasource(params),
|
||||
|
@ -258,8 +252,10 @@ void sqlite_datasource::bind() const
|
|||
{
|
||||
// TODO - we can't trust so much the rowid here
|
||||
if (key_field_ == "rowid")
|
||||
{
|
||||
desc_.add_descriptor(attribute_descriptor("rowid", mapnik::Integer));
|
||||
}
|
||||
}
|
||||
|
||||
if (use_pragma_table_info)
|
||||
{
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
*
|
||||
* 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
|
||||
* 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
|
||||
*
|
||||
*****************************************************************************/
|
||||
//$Id$
|
||||
|
||||
#ifndef SQLITE_DATASOURCE_HPP
|
||||
#define SQLITE_DATASOURCE_HPP
|
||||
|
@ -38,8 +37,6 @@
|
|||
#include "sqlite_types.hpp"
|
||||
|
||||
|
||||
//==============================================================================
|
||||
|
||||
class sqlite_datasource : public mapnik::datasource
|
||||
{
|
||||
public:
|
||||
|
@ -52,6 +49,7 @@ class sqlite_datasource : public mapnik::datasource
|
|||
mapnik::box2d<double> envelope() const;
|
||||
mapnik::layer_descriptor get_descriptor() const;
|
||||
void bind() const;
|
||||
|
||||
private:
|
||||
mutable mapnik::box2d<double> extent_;
|
||||
mutable bool extent_initialized_;
|
||||
|
@ -80,5 +78,4 @@ class sqlite_datasource : public mapnik::datasource
|
|||
void parse_attachdb(std::string const& attachdb) const;
|
||||
};
|
||||
|
||||
|
||||
#endif // SQLITE_DATASOURCE_HPP
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
*
|
||||
* 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
|
||||
* 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
|
||||
*
|
||||
*****************************************************************************/
|
||||
//$Id$
|
||||
|
||||
// mapnik
|
||||
#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()
|
||||
{
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
*
|
||||
* 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
|
||||
* 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
|
||||
*
|
||||
*****************************************************************************/
|
||||
//$Id$
|
||||
|
||||
#ifndef SQLITE_FEATURESET_HPP
|
||||
#define SQLITE_FEATURESET_HPP
|
||||
|
@ -37,8 +36,6 @@
|
|||
#include "sqlite_types.hpp"
|
||||
|
||||
|
||||
//==============================================================================
|
||||
|
||||
class sqlite_featureset : public mapnik::Featureset
|
||||
{
|
||||
public:
|
||||
|
@ -49,6 +46,7 @@ class sqlite_featureset : public mapnik::Featureset
|
|||
bool using_subquery);
|
||||
virtual ~sqlite_featureset();
|
||||
mapnik::feature_ptr next();
|
||||
|
||||
private:
|
||||
boost::shared_ptr<sqlite_resultset> rs_;
|
||||
boost::scoped_ptr<mapnik::transcoder> tr_;
|
||||
|
@ -57,5 +55,4 @@ class sqlite_featureset : public mapnik::Featureset
|
|||
bool using_subquery_;
|
||||
};
|
||||
|
||||
|
||||
#endif // SQLITE_FEATURESET_HPP
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
*
|
||||
* 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
|
||||
* 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
|
||||
*
|
||||
*****************************************************************************/
|
||||
//$Id$
|
||||
|
||||
#ifndef SQLITE_TYPES_HPP
|
||||
#define SQLITE_TYPES_HPP
|
||||
|
||||
// stdc++
|
||||
#include <string.h>
|
||||
// stl
|
||||
#include <cstring>
|
||||
|
||||
// mapnik
|
||||
#include <mapnik/datasource.hpp>
|
||||
|
@ -40,32 +39,25 @@ extern "C" {
|
|||
}
|
||||
|
||||
|
||||
//==============================================================================
|
||||
|
||||
class sqlite_utils
|
||||
{
|
||||
public:
|
||||
|
||||
static void dequote(std::string& z)
|
||||
{
|
||||
boost::algorithm::trim_if(z, boost::algorithm::is_any_of("[]'\"`"));
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
//==============================================================================
|
||||
|
||||
class sqlite_resultset
|
||||
{
|
||||
public:
|
||||
|
||||
sqlite_resultset(sqlite3_stmt* stmt)
|
||||
: stmt_(stmt)
|
||||
{
|
||||
}
|
||||
|
||||
~sqlite_resultset ()
|
||||
virtual ~sqlite_resultset()
|
||||
{
|
||||
if (stmt_)
|
||||
{
|
||||
|
@ -160,8 +152,6 @@ private:
|
|||
};
|
||||
|
||||
|
||||
//==============================================================================
|
||||
|
||||
class sqlite_connection
|
||||
{
|
||||
public:
|
||||
|
@ -204,10 +194,16 @@ public:
|
|||
{
|
||||
std::ostringstream s;
|
||||
s << "Sqlite Plugin: ";
|
||||
|
||||
if (db_)
|
||||
{
|
||||
s << "'" << sqlite3_errmsg(db_) << "'";
|
||||
}
|
||||
else
|
||||
{
|
||||
s << "unknown error, lost connection";
|
||||
}
|
||||
|
||||
s << "\nFull sql was: '" << sql << "'\n";
|
||||
|
||||
throw mapnik::datasource_exception (s.str());
|
||||
|
@ -251,5 +247,4 @@ private:
|
|||
sqlite3* db_;
|
||||
};
|
||||
|
||||
|
||||
#endif // SQLITE_TYPES_HPP
|
||||
|
|
Loading…
Add table
Reference in a new issue