2006-03-31 10:32:02 +00:00
|
|
|
/*****************************************************************************
|
|
|
|
*
|
|
|
|
* This file is part of Mapnik (c++ mapping toolkit)
|
2005-06-14 15:06:59 +00:00
|
|
|
*
|
2006-03-31 10:32:02 +00:00
|
|
|
* Copyright (C) 2006 Artem Pavlenko
|
2005-06-14 15:06:59 +00:00
|
|
|
*
|
2006-03-31 10:32:02 +00:00
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
2005-06-14 15:06:59 +00:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2006-03-31 10:32:02 +00:00
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
2005-06-14 15:06:59 +00:00
|
|
|
*
|
2006-03-31 10:32:02 +00:00
|
|
|
*****************************************************************************/
|
2005-06-14 15:06:59 +00:00
|
|
|
|
|
|
|
//$Id$
|
|
|
|
|
|
|
|
#ifndef ATTRIBUTE_DESCRIPTOR
|
|
|
|
#define ATTRIBUTE_DESCRIPTOR
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
|
2006-10-04 11:22:18 +00:00
|
|
|
namespace mapnik {
|
2011-07-11 21:03:39 +00:00
|
|
|
|
|
|
|
enum eAttributeType {
|
|
|
|
Integer=1,
|
|
|
|
Float =2,
|
|
|
|
Double =3,
|
|
|
|
String =4,
|
|
|
|
Geometry=5,
|
|
|
|
Object=6
|
|
|
|
};
|
|
|
|
|
|
|
|
class attribute_descriptor
|
2010-06-02 11:03:30 +00:00
|
|
|
{
|
2011-07-11 21:03:39 +00:00
|
|
|
public:
|
|
|
|
attribute_descriptor(std::string const& name,unsigned type,
|
|
|
|
bool primary_key=false,
|
|
|
|
int size=-1,
|
|
|
|
int precision=-1)
|
|
|
|
: name_(name),
|
|
|
|
type_(type),
|
|
|
|
primary_key_(primary_key),
|
|
|
|
size_(size),
|
|
|
|
precision_(precision) {}
|
|
|
|
|
|
|
|
attribute_descriptor(attribute_descriptor const& other)
|
|
|
|
: name_(other.name_),
|
|
|
|
type_(other.type_),
|
|
|
|
primary_key_(other.primary_key_),
|
|
|
|
size_(other.size_),
|
|
|
|
precision_(other.precision_) {}
|
|
|
|
|
|
|
|
attribute_descriptor& operator=(attribute_descriptor const& other)
|
|
|
|
{
|
|
|
|
if (this == &other)
|
|
|
|
return *this;
|
|
|
|
name_=other.name_;
|
|
|
|
type_=other.type_;
|
|
|
|
primary_key_=other.primary_key_;
|
|
|
|
size_=other.size_;
|
|
|
|
precision_=other.precision_;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string const& get_name() const
|
|
|
|
{
|
|
|
|
return name_;
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned get_type() const
|
|
|
|
{
|
|
|
|
return type_;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool is_primary_key() const
|
|
|
|
{
|
|
|
|
return primary_key_;
|
|
|
|
}
|
|
|
|
|
|
|
|
int get_size() const
|
|
|
|
{
|
|
|
|
return size_;
|
|
|
|
}
|
|
|
|
|
|
|
|
int get_precision() const
|
|
|
|
{
|
|
|
|
return precision_;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
std::string name_;
|
|
|
|
int type_;
|
|
|
|
bool primary_key_;
|
|
|
|
int size_;
|
|
|
|
int precision_;
|
2010-06-02 11:03:30 +00:00
|
|
|
};
|
2011-07-11 21:03:39 +00:00
|
|
|
|
|
|
|
template <typename charT,typename traits>
|
|
|
|
inline std::basic_ostream<charT,traits>&
|
|
|
|
operator << (std::basic_ostream<charT,traits>& out,
|
|
|
|
attribute_descriptor const& ad)
|
|
|
|
{
|
|
|
|
out << "name=" << ad.get_name() << "\n";
|
|
|
|
out << "type=" << ad.get_type() << "\n";
|
|
|
|
out << "size=" << ad.get_size() << "\n";
|
|
|
|
return out;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-06-14 15:06:59 +00:00
|
|
|
}
|
|
|
|
|
2006-10-04 11:22:18 +00:00
|
|
|
#endif // ATTRIBUTE_DESCRIPTOR_HPP
|