13 #include <boost/shared_ptr.hpp>
14 #include <boost/function.hpp>
15 #include <boost/variant.hpp>
19 namespace MAKVRinTerra
33 typedef boost::shared_ptr<DtFeature>
Ptr;
34 typedef boost::shared_ptr<const DtFeature>
CPtr;
37 typedef boost::variant<
52 String(
const std::string&);
55 const char* c_str()
const;
57 bool operator==(
const String&)
const;
58 bool operator!=(
const String&)
const;
59 bool operator<(
const String&)
const;
65 Key(
const std::string& name,
unsigned index = 0);
66 Key(
const String& name,
unsigned index = 0);
67 Key(
const char* name,
unsigned index = 0);
68 Key(
const Key& key,
unsigned index = 0);
70 bool operator== (
const Key&)
const;
71 bool operator!= (
const Key&)
const;
72 bool operator< (
const Key&)
const;
92 static std::string TypeOfAttribute(
const Attribute&);
98 static Ptr CreateEmptyFeature();
105 static Ptr CreateGeometryFeature(
121 virtual CPtr getPtr()
const;
134 virtual unsigned numberOfAttributes(
const Key::String &)
const = 0;
137 virtual bool hasAttribute(
const Key & k)
const;
140 virtual boost::optional<Attribute> attribute(
const Key &)
const = 0;
142 template <
typename T>
143 boost::optional<T> attributeAs(
const Key& k)
const
145 if (boost::optional<Attribute> attr = attribute(k))
148 return boost::optional<T>();
151 template <
typename Feature>
155 template <
typename T>
158 template <
typename From>
159 boost::optional<T> operator()(
const From& from)
const
163 return boost::lexical_cast<T>(from);
165 catch (boost::bad_lexical_cast&)
167 return boost::optional<T>();
173 template <
typename Feature>
179 typedef typename Feature::Key
Key;
181 typename Feature::CPtr
getPtr()
const {
return typename Feature::Ptr(
clone()); }