From 23546a42245481dfc923aaa33ab2b0a72a4ba778 Mon Sep 17 00:00:00 2001
From: Thomas Gelf <thomas@gelf.net>
Date: Sun, 16 Nov 2014 15:22:54 +0100
Subject: [PATCH] Livestatus\Query: parse an array structure

---
 library/Icinga/Protocol/Livestatus/Query.php | 22 ++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/library/Icinga/Protocol/Livestatus/Query.php b/library/Icinga/Protocol/Livestatus/Query.php
index 432802c7e..0af830032 100644
--- a/library/Icinga/Protocol/Livestatus/Query.php
+++ b/library/Icinga/Protocol/Livestatus/Query.php
@@ -20,6 +20,28 @@ class Query extends SimpleQuery
         return $this->columns;
     }
 
+    /**
+     * Parse the given encoded array
+     *
+     * @param string $str the encoded array string
+     *
+     * @return array
+     */
+    public function parseArray($str)
+    {
+        if (empty($str)) {
+            return array();
+        }
+
+        $result = array();
+        $entries = preg_split('/,/', $str);
+        foreach ($entries as $e) {
+            $result[] = preg_split('/;/', $e);
+        }
+
+        return $result;
+    }
+
     public function getColumnAliases()
     {
         $aliases = array();