diff options
Diffstat (limited to 'include/gras')
-rw-r--r-- | include/gras/CMakeLists.txt | 2 | ||||
-rw-r--r-- | include/gras/block.hpp | 2 | ||||
-rw-r--r-- | include/gras/block.i | 1 | ||||
-rw-r--r-- | include/gras/tag_iter.hpp | 18 | ||||
-rw-r--r-- | include/gras/tag_iter.i | 45 | ||||
-rw-r--r-- | include/gras/tags.hpp | 16 | ||||
-rw-r--r-- | include/gras/tags.i | 23 |
7 files changed, 67 insertions, 40 deletions
diff --git a/include/gras/CMakeLists.txt b/include/gras/CMakeLists.txt index fe11faf..e8fb85e 100644 --- a/include/gras/CMakeLists.txt +++ b/include/gras/CMakeLists.txt @@ -16,6 +16,8 @@ install(FILES sbuffer.i tags.hpp tags.i + tag_iter.hpp + tag_iter.i thread_pool.hpp top_block.hpp work_buffer.hpp diff --git a/include/gras/block.hpp b/include/gras/block.hpp index acdcda1..70654bf 100644 --- a/include/gras/block.hpp +++ b/include/gras/block.hpp @@ -5,7 +5,7 @@ #include <gras/element.hpp> #include <gras/sbuffer.hpp> -#include <gras/tags.hpp> +#include <gras/tag_iter.hpp> #include <gras/work_buffer.hpp> #include <vector> #include <string> diff --git a/include/gras/block.i b/include/gras/block.i index 53458eb..80c3905 100644 --- a/include/gras/block.i +++ b/include/gras/block.i @@ -9,6 +9,7 @@ %include <gras/element.i> %import <gras/tags.i> +%include <gras/tag_iter.i> %import <gras/sbuffer.i> %include <gras/block.hpp> diff --git a/include/gras/tag_iter.hpp b/include/gras/tag_iter.hpp new file mode 100644 index 0000000..81e3c8a --- /dev/null +++ b/include/gras/tag_iter.hpp @@ -0,0 +1,18 @@ +// Copyright (C) by Josh Blum. See LICENSE.txt for licensing information. + +#ifndef INCLUDED_GRAS_TAG_ITER_HPP +#define INCLUDED_GRAS_TAG_ITER_HPP + +#include <gras/gras.hpp> +#include <gras/tags.hpp> +#include <boost/range.hpp> //iterator range +#include <vector> + +namespace gras +{ + //! Iterator return type stl and boost compliant + typedef boost::iterator_range<std::vector<Tag>::const_iterator> TagIter; + +} //namespace gras + +#endif /*INCLUDED_GRAS_TAG_ITER_HPP*/ diff --git a/include/gras/tag_iter.i b/include/gras/tag_iter.i new file mode 100644 index 0000000..91d9054 --- /dev/null +++ b/include/gras/tag_iter.i @@ -0,0 +1,45 @@ +// Copyright (C) by Josh Blum. See LICENSE.txt for licensing information. + +#ifndef INCLUDED_GRAS_TAG_ITER_I +#define INCLUDED_GRAS_TAG_ITER_I + +%{ +#include <gras/tag_iter.hpp> +%} + +%include <gras/gras.hpp> +%import <gras/tags.i> +%include <gras/tag_iter.hpp> + +//////////////////////////////////////////////////////////////////////// +// Turn TagIter into a python iterable object +//////////////////////////////////////////////////////////////////////// +namespace gras +{ + struct TagIter + { + //empty + }; +} + +%extend gras::TagIter +{ + %insert("python") + %{ + def __iter__(self): + for i in range(len(self)): + yield self[i] + %} + + size_t __len__(void) const + { + return ($self)->size(); + } + + const Tag & __getitem__(const size_t i) const + { + return (*($self))[i]; + } +} + +#endif /*INCLUDED_GRAS_TAG_ITER_I*/ diff --git a/include/gras/tags.hpp b/include/gras/tags.hpp index 58eb058..e3c8982 100644 --- a/include/gras/tags.hpp +++ b/include/gras/tags.hpp @@ -94,20 +94,4 @@ GRAS_API bool operator==(const PacketMsg &lhs, const PacketMsg &rhs); } //namespace gras -#include <boost/range.hpp> //iterator range -#include <vector> - -namespace gras -{ - //! Iterator return type stl and boost compliant - //typedef boost::iterator_range<std::vector<Tag>::const_iterator> TagIter; - struct TagIter : boost::iterator_range<std::vector<Tag>::const_iterator> - { - TagIter(void){} - template <typename T> - TagIter(const T &t0, const T &t1): boost::iterator_range<std::vector<Tag>::const_iterator>(t0, t1){} - }; - -} //namespace gras - #endif /*INCLUDED_GRAS_TAGS_HPP*/ diff --git a/include/gras/tags.i b/include/gras/tags.i index 18b3932..33838e2 100644 --- a/include/gras/tags.i +++ b/include/gras/tags.i @@ -12,27 +12,4 @@ %import <gras/sbuffer.i> %import <PMC/PMC.i> -//////////////////////////////////////////////////////////////////////// -// Turn TagIter into a python iterable object -//////////////////////////////////////////////////////////////////////// -%extend gras::TagIter -{ - %insert("python") - %{ - def __iter__(self): - for i in range(len(self)): - yield self[i] - %} - - size_t __len__(void) const - { - return ($self)->size(); - } - - const Tag & __getitem__(const size_t i) const - { - return (*($self))[i]; - } -} - #endif /*INCLUDED_GRAS_TAGS_I*/ |