39 typedef std::vector<std::vector<char> >
Vectors ;
46 class vectors_const_byte_iterator ;
47 class vectors_streambuf ;
58 typedef imp::vectors_streambuf streambuf_type ;
59 typedef imp::vectors_const_byte_iterator const_byte_iterator ;
60 typedef Vectors::iterator row_iterator ;
61 typedef Vectors::const_iterator const_row_iterator ;
71 size_t size_of(
const Vectors & vectors ) ;
72 void resize(
Vectors & vectors ,
int dx ,
int dy ,
int channels ) ;
73 imp::vectors_const_byte_iterator bytes_begin(
const Vectors & vectors ) ;
74 imp::vectors_const_byte_iterator bytes_end(
const Vectors & ) ;
75 bool row_empty( Vectors::iterator row_p ) ;
76 void row_resize( Vectors::iterator row_p ,
size_t n ) ;
77 Vectors::iterator row_erase(
Vectors & vectors , Vectors::iterator row_p ) ;
78 Vectors::const_iterator row_begin(
const Vectors & vectors ) ;
79 Vectors::iterator row_begin(
Vectors & vectors ) ;
80 Vectors::const_iterator row_end(
const Vectors & vectors ) ;
81 Vectors::iterator row_end(
Vectors & vectors ) ;
82 Vectors::iterator row_add(
Vectors & vectors ) ;
83 char * row_ptr( Vectors::iterator row_p ) ;
84 const char * row_ptr( Vectors::const_iterator row_p ) ;
85 size_t row_size( Vectors::const_iterator row_p ) ;
88 std::istream & operator>>( std::istream & stream ,
Gr::Vectors & ) ;
89 std::ostream & operator<<( std::ostream & stream ,
const Gr::Vectors & ) ;
103 virtual std::streamsize
xsgetn(
char * s , std::streamsize n )
override ;
106 virtual std::streampos
seekpos( std::streampos pos , std::ios_base::openmode which )
override ;
109 virtual std::streampos
seekoff( std::streamoff off , std::ios_base::seekdir way , std::ios_base::openmode which )
override ;
118 void setg_imp(
const char * ,
const char * ,
const char * ) ;
119 std::streampos pos()
const ;
120 std::streampos seek( std::streamoff off ) ;
122 const char * cbuf_head()
const ;
123 const char * cbuf_tail()
const ;
124 size_t cbuf_available()
const ;
125 size_t cbuf_available(
const char * )
const ;
126 size_t cbuf_offset()
const ;
127 size_t cbuf_offset(
const char * )
const ;
131 Vectors::const_iterator m_current ;
132 Vectors::const_iterator m_end ;
133 std::streampos m_size ;
165 Vectors::const_iterator m_current ;
166 size_t m_current_offset ;
174 imp::hexdump_streamable<N,Gr::Vectors,typename imp::hexdump_tohex,typename imp::hexdump_toprintable>
178 iterator begin( v ) ;
180 return hexdump<N>( begin , end ) ;
186 size_t Gr::imagebuffer::size_of(
const Vectors & vectors )
189 add_size< std::vector<char> > adder( n ) ;
190 std::for_each( vectors.begin() , vectors.end() , adder ) ;
195 void Gr::imagebuffer::resize(
Vectors & vectors ,
int dx ,
int dy ,
int channels )
197 if( dx > 0 && dy > 0 && channels > 0 )
199 vectors.resize( dy ) ;
200 size_t drow = sizet(dx,channels) ;
201 for(
int y = 0 ; y < dy ; y++ )
203 vectors.at(y).resize( drow ) ;
211 return imp::vectors_const_byte_iterator( vectors ) ;
217 return imp::vectors_const_byte_iterator() ;
221 bool Gr::imagebuffer::row_empty( Vectors::iterator row_p )
223 return (*row_p).empty() ;
227 void Gr::imagebuffer::row_resize( Vectors::iterator row_p ,
size_t n )
229 (*row_p).resize( n ) ;
233 Gr::Vectors::iterator Gr::imagebuffer::row_erase(
Vectors & vectors , Vectors::iterator row_p )
235 return vectors.erase( row_p , vectors.end() ) ;
239 Gr::Vectors::const_iterator Gr::imagebuffer::row_begin(
const Vectors & vectors )
241 return vectors.begin() ;
245 Gr::Vectors::iterator Gr::imagebuffer::row_begin(
Vectors & vectors )
247 return vectors.begin() ;
251 Gr::Vectors::const_iterator Gr::imagebuffer::row_end(
const Vectors & vectors )
253 return vectors.end() ;
257 Gr::Vectors::iterator Gr::imagebuffer::row_end(
Vectors & vectors )
259 return vectors.end() ;
263 Gr::Vectors::iterator Gr::imagebuffer::row_add(
Vectors & vectors )
265 vectors.push_back( std::vector<char>() ) ;
266 return vectors.begin() + (vectors.size()-1U) ;
270 char * Gr::imagebuffer::row_ptr( Vectors::iterator row_p )
272 return &(*row_p)[0] ;
276 const char * Gr::imagebuffer::row_ptr( Vectors::const_iterator row_p )
278 return &(*row_p)[0] ;
282 size_t Gr::imagebuffer::row_size( Vectors::const_iterator row_p )
284 return (*row_p).size() ;
291 m_current_offset(0U) ,
298 m_vectors(&vectors) ,
299 m_current(vectors.begin()) ,
300 m_current_offset(0U) ,
308 if( m_vectors ==
nullptr || m_current == m_vectors->end() )
return '\0' ;
309 return (*m_current).at(m_current_offset) ;
315 if( m_vectors !=
nullptr && m_current != m_vectors->end() )
319 if( m_current_offset == (*m_current).size() )
321 for( ++m_current ; m_current != m_vectors->end() && (*m_current).empty() ; )
323 m_current_offset = 0U ;
340 bool this_end = m_vectors ==
nullptr || m_current == m_vectors->end() ;
341 bool other_end = m_vectors ==
nullptr || m_current == m_vectors->end() ;
343 ( this_end && other_end ) ||
344 ( m_vectors == other.m_vectors && m_offset == other.m_offset ) ;
350 return !( *
this == other ) ;
A simple, read-only streambuf for Gr::Vectors.
A forward byte-by-byte input iterator for Gr::ImageVectors.
A traits class that can be specialised for Gr::ImageBuffer candidates.
bool operator!=(const vectors_const_byte_iterator &) const
Inequality operator.
bool operator==(const vectors_const_byte_iterator &) const
Equality operator.
std::vector< std::vector< char > > Vectors
A candidate for Gr::ImageBuffer that uses nested std::vectors.
vectors_const_byte_iterator & operator++()
Preincrement operator.
virtual std::streampos seekoff(std::streamoff off, std::ios_base::seekdir way, std::ios_base::openmode which) override
Override from std::streambuf.
vectors_const_byte_iterator()
Default constructor for an end iterator.
virtual std::streampos seekpos(std::streampos pos, std::ios_base::openmode which) override
Override from std::streambuf.
virtual std::streamsize xsgetn(char *s, std::streamsize n) override
Override from std::streambuf.
virtual int underflow() override
Override from std::streambuf.
virtual ~vectors_streambuf()
Destructor.
vectors_streambuf(const Vectors &)
Constructor.
char operator*() const
Dereference operator.
imp::hexdump_streamable< N, T, Ttohex, Ttoprintable > hexdump(T begin, T end, unsigned int address_width, const char *prefix, const char *space, const char *bar, unsigned int width, Ttohex tohex, Ttoprintable toprintable)
Returns a streamable object that does a hex dump.