Commit Graph

67 Commits

Author SHA1 Message Date
PB
83a2a1e505 Refactor the natural string compare and sort algorithm
Add a new string fragment type for whitespace and punctuation which needs
to be assessed separately from letters and symbols.

Use wxUint64 instead of long for storing the value for numeric fragment.

Use collate instead of compare for non-numeric fragments.

Change names for the public comparison functions: wxWidgets provided function
is now named wxCmpGenericNatural() and for common public use is wxCmpNatural()
which calls a native function in wxMSW and wxCmpGenericNatural() elsewhere.

Try harder in wxCmpNaturalGeneric() if wxRegEx is unavailable: do not
just make a simple string comparison, but perform a case-insensitive
collation.

Make some other changes to simplify and possibly speed up the code.
2020-07-07 23:10:18 +02:00
Hugo Elias
371c4b1366 Add functions for sorting strings in natural sort order
Use StrCmpLogicalW() under MSW and generic implementation under the
other platforms.

See https://github.com/wxWidgets/wxWidgets/pull/780
2020-07-07 23:10:11 +02:00
Paul Cornett
a3598ba33f Remove unnecessary copy ctors/copy assignment operators
C++11 deprecates having one without the other.
Eliminates many, many GCC -Wdeprecated-copy warnings.
2019-10-14 09:07:21 -07:00
orbitcowboy
8dfd799fd5 Use const for constant local variables in wxWidgets headers
This avoids warnings from MSVS 2017 static analyzer when C++ core rule
set is activated.

Closes https://github.com/wxWidgets/wxWidgets/pull/819
2018-07-21 16:16:32 +02:00
Vadim Zeitlin
17c7048f36 Fix crash when appending items of empty vector to wxItemContainer
Passing an empty std::vector<wxString> to Append() or Insert() methods
of any wxItemContainer-derived classes, such as e.g. wxComboBox,
resulted in undefined behaviour due to accessing the first element of an
empty vector.

Fix this by avoiding using it when the vector is empty.
2018-06-29 14:33:56 +02:00
Vadim Zeitlin
93edcaef20 Fix wrong function pointer casts in dynamic arrays code
Don't cast function pointers of incompatible types, this resulted in gcc
8 -Wcast-function-type warnings and could hide real errors.

To fix this, overload wxBaseArray::Sort() to accept either the "legacy"
sort function compatible with qsort() or a function compatible with
std::sort(), as it seems both variants could be used before. Also make
the type of the latter function customizable via a new optional Sorter
template parameter in wxBaseArray in order to allow wxSortedArrayString
to specify its own variant of it, taking (const) references instead of
values.

This complicates things, but should preserve compatibility while being
type-safe and, also, allows to simplify _WX_DEFINE_SORTED_TYPEARRAY_2 by
not passing the sort function signature to it any more.
2018-06-10 23:51:13 +02:00
Vadim Zeitlin
b0d6b11ebe Always use wxVector<> for dynamic arrays implementation
Dramatically simplify dynamic array macros by keeping only the
implementation previously used in wxUSE_STD_CONTAINERS case and dropping
the other one, as we can use the std::vector-based implementation on top
of our own wxVector<>, which is available whether wxUSE_STD_CONTAINERS
is 0 or 1.

This allows to get rid of tons of ugly macro-based code without breaking
compatibility.
2018-06-02 13:56:06 +02:00
Vadim Zeitlin
da36cbff06 Don't over promise in wxItemContainer documentation
It only accepts std::vector<wxString>, not std::vector<T> for any type
convertible to wxString as both the documentation and the code misleadingly
claimed.
2017-01-14 00:25:35 +01:00
ARATA Mizuki
8cfc74491a Replace wxEXPLICIT with the 'explicit' keyword
See #17655.
2016-09-14 18:45:12 +09:00
Vadim Zeitlin
6f2fdbae6a Fix typo in a comment.
s/minimzes/minimizes/
2015-06-19 13:40:41 +02:00
Vadim Zeitlin
722057b3a0 Add a new wxUSE_STD_CONTAINERS_COMPATIBLY option.
This option, which is on by default unless the use of STL is disabled,
provides better interoperability with the standard library when it can be done
without breaking backwards compatibility.

The first example of its use is to allow passing std::vector<> of any string
compatible type to wxItemContainer::Append(), Insert() and Set(), allowing to
directly initialize various wxControls deriving from it such as wxChoice,
wxComboBox, wxListBox from a std::vector<> of strings.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@78066 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2014-10-24 21:54:51 +00:00
Vadim Zeitlin
45adc64f9f Fix inserting an element of wxArrayString itself back into it.
Do the insertion/addition before deallocating the old memory to allow things
like array.Add(array[0]) to work correctly.

Closes #2290.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@76909 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2014-07-13 14:30:22 +00:00
Vadim Zeitlin
af77028fcf Add wxDictionaryStringSortAscending comparison function.
Add "dictionary sort" callbacks and document them and the already existing
wxStringSortAscending() and wxStringSortDescending().

See #16330.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@76753 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2014-06-23 12:02:09 +00:00
Vadim Zeitlin
e2e79bd000 Allow specifying custom comparator for wxSortedArrayString.
Add a possibility to order wxSortedArrayString in some order different from
the default alphabetical one.

Closes #16330.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@76751 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2014-06-23 01:08:50 +00:00
Vadim Zeitlin
8161cf19e9 Change wxStringSort{As,De}cending() to use references, not pointers.
This is more convenient to use and makes more sense as the arguments are never
null.

See #16330.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@76750 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2014-06-23 01:08:44 +00:00
Vadim Zeitlin
f4b80e5337 Remove MSVC6 support.
Don't support this compiler any more, this allows to get rid of tons of
MSVC6-specific workarounds, in particular we can now use Bind() and natural
template functions calls in the library code.

Also remove MSVC6 project and solution files and don't generate them when
bakefile_gen is ran any more (removing the remaining occurrences of msvc6prj
from the bakefiles results in weird bake-time errors, so it's simpler to just
leave them there).

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@76532 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2014-05-15 22:32:17 +00:00
Vadim Zeitlin
3f66f6a5b3 Remove all lines containing cvs/svn "$Id$" keyword.
This keyword is not expanded by Git which means it's not replaced with the
correct revision value in the releases made using git-based scripts and it's
confusing to have lines with unexpanded "$Id$" in the released files. As
expanding them with Git is not that simple (it could be done with git archive
and export-subst attribute) and there are not many benefits in having them in
the first place, just remove all these lines.

If nothing else, this will make an eventual transition to Git simpler.

Closes #14487.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@74602 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2013-07-26 16:02:46 +00:00
Stefan Neis
05e66a7002 No real changes, just spelling fixes to comments. Closes #15030.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@73571 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2013-02-27 12:05:17 +00:00
Vadim Zeitlin
01871bf642 Add wxUSE_STD_CONTAINERS and turn it on by default.
Previously, wxUSE_STL enabled both implicit conversion of wxString to
std::[w]string and use of standard containers for the implementation of their
wx equivalents. Split up the two roles now by allowing to enable the use of
the standard containers independently of (backwards incompatible) implicit
conversion in wxString and actually enable wxUSE_STD_CONTAINERS by default.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@67343 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2011-03-30 14:16:04 +00:00
Stefan Csomor
4472e2b6b7 using explicit fixes #12689
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@66724 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2011-01-20 08:38:36 +00:00
Paul Cornett
d6d6a61fed proper const-ness for Item(), operator[](), and Last()
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@66652 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2011-01-08 17:16:29 +00:00
Vadim Zeitlin
233f573883 Fix file paths in the header comments.
Consistently use only "wx/foo.h" instead of "include/wx/foo.h" ("include" is
always implicit anyhow).

Also use "src/osx" instead of "src/mac" for the files in this directory.

See #12165.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@64943 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2010-07-13 13:29:58 +00:00
Václav Slavík
2ab514cad4 Make the wxArrayString(int) ctor explicit.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@64606 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2010-06-17 13:04:21 +00:00
Vadim Zeitlin
9a83f86094 Globally replace _T() with wxT().
Standardize on using a single macro across all wxWidgets sources and solve the name clash with Sun CC standard headers (see #10660).

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@61508 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2009-07-23 20:30:22 +00:00
Vadim Zeitlin
795ac80edb make wxSortedArrayString::Sort() and Insert() private in STL build (closes #10947)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@61268 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2009-07-01 08:56:31 +00:00
Vadim Zeitlin
0330301cb3 compilation fix after last commit
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@59142 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2009-02-25 23:27:07 +00:00
Vadim Zeitlin
936525578d don't use template assign() with VC6, even though it can compile it it doesn't handle it correctly when using DLL
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@59141 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2009-02-25 23:02:53 +00:00
Vadim Zeitlin
d11c9d86b6 made wxArrayString::assign(iterator, iterator) a template function; also fixed a bad bug in it: it didn't call clear(); mention existence of std::vector-like methods in the docs
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@58843 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2009-02-12 12:09:13 +00:00
Vadim Zeitlin
c0c133e13b add wx-prefixed and semicolon-requiring versions of DECLARE_NO_{COPY,ASSIGN}_CLASS macros
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@58757 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2009-02-08 11:45:59 +00:00
Vadim Zeitlin
d3960469fc implement const rbegin/rend() versions (closes #3866)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@56822 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2008-11-17 14:07:51 +00:00
Václav Slavík
4f24cbbd3d implement wxWindow::DragAcceptFiles() on all platforms
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@56757 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2008-11-13 22:30:40 +00:00
Vadim Zeitlin
1372f8ccd0 use wxSwap()
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@55650 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2008-09-15 16:13:06 +00:00
Vadim Zeitlin
9127686895 added wxArrayString::swap()
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@55549 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2008-09-11 13:35:32 +00:00
Vadim Zeitlin
eea2be6ca3 define wxStringSortAscneding/Descending() even in non-STL build for compatibility
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@55401 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2008-09-01 00:50:40 +00:00
Vadim Zeitlin
9c7c6fa27b fix wxUSE_STL compilation after latest changes
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@55391 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2008-08-31 14:39:08 +00:00
Vadim Zeitlin
eaf6da0746 use std::sort() instead of qsort() to implement wxArrayString::Sort(), this makes it thread-safe without any extra hacks and also makes the code simpler
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@55317 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2008-08-27 19:40:20 +00:00
Vadim Zeitlin
1b6d87d08e use size_t instead of unsigned int to avoid MSVC warnings about converting the former to the latter when compiling with /Wp64
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@50242 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2007-11-25 14:28:54 +00:00
Vadim Zeitlin
a236aa2058 many wxItemContainer-related changes:
1. the main function for item insertion is now DoInsertItems() which allows
   for much more efficient addition of many new items at once
2. the items client data management is done entirely in wxItemContainer
   itself, the derived classes don't have to distinguish between void and
   object client data
3. many fixes for sorted controls, in particular implemented wxCB_SORT support
   in wxGTK combobox


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@47730 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2007-07-26 13:54:14 +00:00
Václav Slavík
87f351de6c STL compilation fix
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@47045 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2007-06-30 11:17:35 +00:00
Václav Slavík
cfa3d7ba83 ANSI+Unicode compatibility fixes to wxArrayString
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@47009 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2007-06-28 18:56:00 +00:00
Václav Slavík
8650108199 don't use implicit wxString->char*/wchar_t* conversion, it will not be available in wxUSE_STL build in the future
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@46391 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2007-06-10 17:42:41 +00:00
Vadim Zeitlin
b4a980f4f5 don't use obsolete functions (mostly copystring() and Count()), remove their documentation (patch 1697956)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@45395 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2007-04-11 00:23:19 +00:00
Václav Slavík
6580df1b72 fixed missing ; after class declaration
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@44947 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2007-03-19 17:27:08 +00:00
Vadim Zeitlin
abbb59e8eb added wxJoin and wxSplit functions (modified patch 1638950)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@44890 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2007-03-18 14:43:41 +00:00
Václav Slavík
b7452b3a0e removed wxArrayString casting hack, it doesn't work with the new wxString class
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@44848 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2007-03-16 12:57:46 +00:00
Vadim Zeitlin
c1dc9f8394 removed WXWIN_COMPATIBILITY_2_4 from common and wxMSW files (patch 1675546)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@44625 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2007-03-07 11:35:04 +00:00
Václav Slavík
001ad728a4 changed wxArrayString::m_pItems from wxChar* to const wxChar*, the strings are not modified by the class
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@44563 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2007-02-24 15:19:16 +00:00
Mattia Barbon
555d0d7ef1 Correct wxArrayString::Add return value as per the documentation.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@33888 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2005-04-26 19:24:12 +00:00
Julian Smart
d44d0cbd73 Added C/wxString array constructors to wxArrayString
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@33074 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2005-03-26 14:18:56 +00:00
Vadim Zeitlin
60d8e88654 iterator methods fixes (patch 1164808)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@32876 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2005-03-17 23:19:13 +00:00