Audacity 3.2.0
wxArrayStringEx.h
Go to the documentation of this file.
1/**********************************************************************
2
3 Audacity: A Digital Audio Editor
4
5 @file wxArrayStringEx.h
6
7 Paul Licameli split from MemoryX.h
8
9 **********************************************************************/
10
11#ifndef __AUDACITY_WX_ARRAY_STRING_EX__
12#define __AUDACITY_WX_ARRAY_STRING_EX__
13
14#include <wx/arrstr.h>
15
17class wxArrayStringEx : public wxArrayString
18{
19public:
20 using wxArrayString::wxArrayString;
21 wxArrayStringEx() = default;
22
23 template< typename Iterator >
24 wxArrayStringEx( Iterator start, Iterator finish )
25 {
26 this->reserve( std::distance( start, finish ) );
27 while( start != finish )
28 this->push_back( *start++ );
29 }
30
31 template< typename T >
32 wxArrayStringEx( std::initializer_list< T > items )
33 {
34 this->reserve( this->size() + items.size() );
35 for ( const auto &item : items )
36 this->push_back( item );
37 }
38
40 wxArrayStringEx( wxArrayString &&other )
41 {
42 swap( other );
43 }
44
46 wxArrayStringEx &operator= ( wxArrayString &&other )
47 {
48 if ( this != &other ) {
49 clear();
50 swap( other );
51 }
52 return *this;
53 }
54
55 using wxArrayString::insert;
56
57 template< typename T >
58 iterator insert( const_iterator pos, std::initializer_list< T > items )
59 {
60 const auto index = pos - ((const wxArrayString*)this)->begin();
61 this->wxArrayString::Insert( {}, index, items.size() );
62 auto result = this->begin() + index, iter = result;
63 for ( auto pItem = items.begin(), pEnd = items.end();
64 pItem != pEnd;
65 ++pItem, ++iter
66 ) {
67 *iter = *pItem;
68 }
69 return result;
70 }
71};
72
73#endif
Extend wxArrayString with move operations and construction and insertion fromstd::initializer_list.
wxArrayStringEx(Iterator start, Iterator finish)
wxArrayStringEx(wxArrayString &&other)
The move operations can take arguments of the base class wxArrayString.
wxArrayStringEx & operator=(wxArrayString &&other)
The move operations can take arguments of the base class wxArrayString.
wxArrayStringEx()=default
iterator insert(const_iterator pos, std::initializer_list< T > items)
wxArrayStringEx(std::initializer_list< T > items)
void swap(std::unique_ptr< Alg_seq > &a, std::unique_ptr< Alg_seq > &b)
Definition: NoteTrack.cpp:634
const char * begin(const char *str) noexcept
Definition: StringUtils.h:101