From ae970f90e526b2ad32faf497caea1297eb46a195 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Wed, 5 Dec 2012 22:07:00 -0800 Subject: moved tag iter into its own header --- include/gras/CMakeLists.txt | 2 ++ include/gras/block.hpp | 2 +- include/gras/block.i | 1 + include/gras/tag_iter.hpp | 18 ++++++++++++++++++ include/gras/tag_iter.i | 45 +++++++++++++++++++++++++++++++++++++++++++++ include/gras/tags.hpp | 16 ---------------- include/gras/tags.i | 23 ----------------------- 7 files changed, 67 insertions(+), 40 deletions(-) create mode 100644 include/gras/tag_iter.hpp create mode 100644 include/gras/tag_iter.i (limited to 'include/gras') 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 #include -#include +#include #include #include #include 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 %import +%include %import %include 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 +#include +#include //iterator range +#include + +namespace gras +{ + //! Iterator return type stl and boost compliant + typedef boost::iterator_range::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 +%} + +%include +%import +%include + +//////////////////////////////////////////////////////////////////////// +// 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 //iterator range -#include - -namespace gras -{ - //! Iterator return type stl and boost compliant - //typedef boost::iterator_range::const_iterator> TagIter; - struct TagIter : boost::iterator_range::const_iterator> - { - TagIter(void){} - template - TagIter(const T &t0, const T &t1): boost::iterator_range::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 %import -//////////////////////////////////////////////////////////////////////// -// 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*/ -- cgit