* point2d.i (__str__): New method (extension).
---
swilena/ChangeLog | 6 ++++++
swilena/point2d.i | 14 +++++++++++++-
2 files changed, 19 insertions(+), 1 deletions(-)
diff --git a/swilena/ChangeLog b/swilena/ChangeLog
index f9bf4a4..07d0481 100644
--- a/swilena/ChangeLog
+++ b/swilena/ChangeLog
@@ -1,3 +1,9 @@
+2009-05-27 Roland Levillain <roland(a)lrde.epita.fr>
+
+ Add conversion to string to point2d.
+
+ * point2d.i (__str__): New method (extension).
+
2009-05-26 Roland Levillain <roland(a)lrde.epita.fr>
Wrap iterators on mln::box2d.
diff --git a/swilena/point2d.i b/swilena/point2d.i
index 2d3df05..0bf9142 100644
--- a/swilena/point2d.i
+++ b/swilena/point2d.i
@@ -1,5 +1,5 @@
// -*- C++ -*-
-// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2008, 2009 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -90,4 +90,16 @@
int col() const { return $self->operator[](1); }
}
+%extend mln::point< mln::grid::square, mln::def::coord >
+{
+ char* __str__() const
+ {
+ std::ostringstream s;
+ s << *$self;
+ // FIXME: This is admittedly ugly; can't we use std::string as
+ // return type? See Swig's manual.
+ return strdup(s.str().c_str());
+ }
+}
+
%template(point2d) mln::point<mln::grid::square, mln::def::coord>;
--
1.6.1.2
Show replies by date