X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;ds=sidebyside;f=classes%2Fplflagset.php;h=c6c8d41f93b123407edf5a4545f95c60c2c6d9fc;hb=feb45d1d9fc152beff746c83048ff7704cc27ea2;hp=474f9d87a2e24ad057f24f99bef256cec85bee9c;hpb=3ecd0a882aebbb539b4b0e507a360e961cd51c63;p=platal.git diff --git a/classes/plflagset.php b/classes/plflagset.php index 474f9d8..c6c8d41 100644 --- a/classes/plflagset.php +++ b/classes/plflagset.php @@ -1,6 +1,6 @@ sep = $sep; $splitted = explode($sep, $flags); foreach ($splitted as $part) { - $this->values[$part] = true; + if (!empty($part)) { + $this->values[$part] = true; + } } } @@ -102,6 +104,13 @@ class PlFlagSet } } + /** Remove all the flags. + */ + public function clear() + { + $this->values = array(); + } + /** return the PlFlagSet */ @@ -118,6 +127,34 @@ class PlFlagSet } return $flags; } + + /** export the PlFlagSet + */ + public function export() + { + $array = array(); + foreach ($this->values as $key=>$value) { + if ($value) { + $array[] = $key; + } + } + return $array; + } + + /** format for XDB + */ + public function format() + { + return XDB::escape($this->flags()); + } + + + /** Build an iterator for this PlFlagSet. + */ + public function iterate() + { + return PlIteratorUtils::fromArray($this->export(), 1, true); + } } // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: