Added C/wxString array constructors to wxArrayString

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@33074 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Julian Smart
2005-03-26 14:18:56 +00:00
parent f36a04a7b6
commit d44d0cbd73
4 changed files with 36 additions and 3 deletions

View File

@@ -14,6 +14,7 @@ All:
- Fixed wxDateTime::SetToWeekDayInSameWeek(Sun, Monday_First). - Fixed wxDateTime::SetToWeekDayInSameWeek(Sun, Monday_First).
- Added WXK_SPECIAL keycodes for special hardware buttons. - Added WXK_SPECIAL keycodes for special hardware buttons.
- Fixed bug with wxFile::Seek(-1, wxFromCurrent) - Fixed bug with wxFile::Seek(-1, wxFromCurrent)
- Added wxString/C array constructors to wxArrayString
All (GUI): All (GUI):

View File

@@ -60,13 +60,21 @@ functions.
\func{}{wxArrayString}{\void} \func{}{wxArrayString}{\void}
Default constructor.
\func{}{wxArrayString}{\param{const wxArrayString\&}{ array}} \func{}{wxArrayString}{\param{const wxArrayString\&}{ array}}
Default and copy constructors. Copy constructor. Note that when an array is assigned to a sorted array, its contents is
Note that when an array is assigned to a sorted array, its contents is
automatically sorted during construction. automatically sorted during construction.
\func{}{wxArrayString}{\param{size\_t}{ sz}, \param{const wxChar**}{ arr}}
Constructor from a C string array. Pass a size {\it sz} and array {\it arr}.
\func{}{wxArrayString}{\param{size\_t}{ sz}, \param{const wxString*}{ arr}}
Constructor from a wxString array. Pass a size {\it sz} and array {\it arr}.
\membersection{wxArrayString::\destruct{wxArrayString}}\label{wxarraystringdtor} \membersection{wxArrayString::\destruct{wxArrayString}}\label{wxarraystringdtor}
\func{}{\destruct{wxArrayString}}{} \func{}{\destruct{wxArrayString}}{}

View File

@@ -42,6 +42,8 @@ public:
wxArrayString() { } wxArrayString() { }
wxArrayString(const wxArrayString& a) : wxArrayStringBase(a) { } wxArrayString(const wxArrayString& a) : wxArrayStringBase(a) { }
wxArrayString(size_t sz, const wxChar** a);
wxArrayString(size_t sz, const wxString* a);
int Index(const wxChar* sz, bool bCase = true, bool bFromEnd = false) const; int Index(const wxChar* sz, bool bCase = true, bool bFromEnd = false) const;
@@ -110,6 +112,10 @@ public:
// of course, using explicit would be even better - if all compilers // of course, using explicit would be even better - if all compilers
// supported it... // supported it...
wxArrayString(int autoSort) { Init(autoSort != 0); } wxArrayString(int autoSort) { Init(autoSort != 0); }
// C string array ctor
wxArrayString(size_t sz, const wxChar** a);
// wxString string array ctor
wxArrayString(size_t sz, const wxString* a);
// copy ctor // copy ctor
wxArrayString(const wxArrayString& array); wxArrayString(const wxArrayString& array);
// assignment operator // assignment operator

View File

@@ -2032,6 +2032,24 @@ int wxString::sprintf(const wxChar *pszFormat, ...)
#include "wx/arrstr.h" #include "wx/arrstr.h"
wxArrayString::wxArrayString(size_t sz, const wxChar** a)
{
#if !wxUSE_STL
Init(false);
#endif
for (size_t i=0; i < sz; i++)
Add(a[i]);
}
wxArrayString::wxArrayString(size_t sz, const wxString* a)
{
#if !wxUSE_STL
Init(false);
#endif
for (size_t i=0; i < sz; i++)
Add(a[i]);
}
#if !wxUSE_STL #if !wxUSE_STL
// size increment = min(50% of current size, ARRAY_MAXSIZE_INCREMENT) // size increment = min(50% of current size, ARRAY_MAXSIZE_INCREMENT)