+class Point {
+ public $x;
+ public $y;
+ function __construct($x, $y) {
+ $this->x = $x;
+ $this->y = $y;
+ }
+}
+
+class Box {
+ public $p1;
+ public $p2;
+ function __construct(Point $p1, Point $p2) {
+ $this->p1 = $p1;
+ $this->p2 = $p2;
+ }
+}
+
+class BoxConverter extends Converter
+{
+ function convertTypes() {
+ return [ $this->types["box"]->oid ];
+ }
+
+ function convertToString($box, $type) {
+ return sprintf("(%F,%F),(%F,%F)",
+ $box->p1->x, $box->p1->y,
+ $box->p2->x, $box->p2->y
+ );
+ }
+
+ function convertFromString($data, $type) {
+ list($p1x, $p1y, $p2x, $p2y) = sscanf($data, "(%f,%f),(%f,%f)");
+ return new Box(new Point($p1x, $p1y), new Point($p2x, $p2y));
+ }
+}
+
+class Text {
+ private $data;
+ function __construct($data) {
+ $this->data = $data;
+ }
+ function __toString() {
+ return (string) $this->data;
+ }
+}
+