add wxString::Capitalize() and MakeCapitalized() for consistency with Upper/Lower() we already have
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@54915 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -288,6 +288,7 @@ All:
|
|||||||
- Fix reading/writing UTF-7-encoded text streams.
|
- Fix reading/writing UTF-7-encoded text streams.
|
||||||
- Corrected bug in wxTimeSpan::IsShorterThan() for equal time spans.
|
- Corrected bug in wxTimeSpan::IsShorterThan() for equal time spans.
|
||||||
- Use std::unordered_{map,set} for wxHashMap/Set if available (Jan van Dijk).
|
- Use std::unordered_{map,set} for wxHashMap/Set if available (Jan van Dijk).
|
||||||
|
- Added wxString::Capitalize() and MakeCapitalized().
|
||||||
|
|
||||||
All (Unix):
|
All (Unix):
|
||||||
|
|
||||||
|
@@ -1704,12 +1704,17 @@ public:
|
|||||||
// convert to upper case in place, return the string itself
|
// convert to upper case in place, return the string itself
|
||||||
wxString& MakeUpper();
|
wxString& MakeUpper();
|
||||||
// convert to upper case, return the copy of the string
|
// convert to upper case, return the copy of the string
|
||||||
// Here's something to remember: BC++ doesn't like returns in inlines.
|
wxString Upper() const { return wxString(*this).MakeUpper(); }
|
||||||
wxString Upper() const ;
|
|
||||||
// convert to lower case in place, return the string itself
|
// convert to lower case in place, return the string itself
|
||||||
wxString& MakeLower();
|
wxString& MakeLower();
|
||||||
// convert to lower case, return the copy of the string
|
// convert to lower case, return the copy of the string
|
||||||
wxString Lower() const ;
|
wxString Lower() const { return wxString(*this).MakeLower(); }
|
||||||
|
// convert the first character to the upper case and the rest to the
|
||||||
|
// lower one, return the modified string itself
|
||||||
|
wxString& MakeCapitalized();
|
||||||
|
// convert the first character to the upper case and the rest to the
|
||||||
|
// lower one, return the copy of the string
|
||||||
|
wxString Capitalize() const { return wxString(*this).MakeCapitalized(); }
|
||||||
|
|
||||||
// trimming/padding whitespace (either side) and truncating
|
// trimming/padding whitespace (either side) and truncating
|
||||||
// remove spaces from left or from right (default) side
|
// remove spaces from left or from right (default) side
|
||||||
|
@@ -463,6 +463,16 @@ public:
|
|||||||
wxString BeforeLast(wxUniChar ch) const;
|
wxString BeforeLast(wxUniChar ch) const;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Return the copy of the string with the first string character in the
|
||||||
|
upper case and the subsequent ones in the lower case.
|
||||||
|
|
||||||
|
@since 2.9.0
|
||||||
|
|
||||||
|
@see MakeCapitalized()
|
||||||
|
*/
|
||||||
|
wxString Capitalize() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Empties the string and frees memory occupied by it.
|
Empties the string and frees memory occupied by it.
|
||||||
See also: Empty()
|
See also: Empty()
|
||||||
@@ -759,6 +769,8 @@ public:
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
Returns this string converted to the lower case.
|
Returns this string converted to the lower case.
|
||||||
|
|
||||||
|
@see MakeLower()
|
||||||
*/
|
*/
|
||||||
wxString Lower() const;
|
wxString Lower() const;
|
||||||
|
|
||||||
@@ -769,13 +781,27 @@ public:
|
|||||||
*/
|
*/
|
||||||
void LowerCase();
|
void LowerCase();
|
||||||
|
|
||||||
|
/**
|
||||||
|
Converts the first characters of the string to the upper case and all
|
||||||
|
the subsequent ones to the lower case and returns the result.
|
||||||
|
|
||||||
|
@since 2.9.0
|
||||||
|
|
||||||
|
@see Capitalize()
|
||||||
|
*/
|
||||||
|
wxString& MakeCapitalized();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Converts all characters to lower case and returns the result.
|
Converts all characters to lower case and returns the result.
|
||||||
|
|
||||||
|
@see Lower()
|
||||||
*/
|
*/
|
||||||
wxString& MakeLower();
|
wxString& MakeLower();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Converts all characters to upper case and returns the result.
|
Converts all characters to upper case and returns the result.
|
||||||
|
|
||||||
|
@see Upper()
|
||||||
*/
|
*/
|
||||||
wxString& MakeUpper();
|
wxString& MakeUpper();
|
||||||
|
|
||||||
@@ -1018,6 +1044,8 @@ public:
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
Returns this string converted to upper case.
|
Returns this string converted to upper case.
|
||||||
|
|
||||||
|
@see MakeUpper()
|
||||||
*/
|
*/
|
||||||
wxString Upper() const;
|
wxString Upper() const;
|
||||||
|
|
||||||
|
@@ -1363,6 +1363,20 @@ wxString& wxString::MakeLower()
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wxString& wxString::MakeCapitalized()
|
||||||
|
{
|
||||||
|
const iterator en = end();
|
||||||
|
iterator it = begin();
|
||||||
|
if ( it != en )
|
||||||
|
{
|
||||||
|
*it = (wxChar)wxToupper(*it);
|
||||||
|
for ( ++it; it != en; ++it )
|
||||||
|
*it = (wxChar)wxTolower(*it);
|
||||||
|
}
|
||||||
|
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
// trimming and padding
|
// trimming and padding
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
@@ -1967,13 +1981,6 @@ int wxString::Freq(wxUniChar ch) const
|
|||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
// convert to upper case, return the copy of the string
|
|
||||||
wxString wxString::Upper() const
|
|
||||||
{ wxString s(*this); return s.MakeUpper(); }
|
|
||||||
|
|
||||||
// convert to lower case, return the copy of the string
|
|
||||||
wxString wxString::Lower() const { wxString s(*this); return s.MakeLower(); }
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// wxUTF8StringBuffer
|
// wxUTF8StringBuffer
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
@@ -366,14 +366,26 @@ void StringTestCase::CaseChanges()
|
|||||||
wxString s1l(s1);
|
wxString s1l(s1);
|
||||||
s1u.MakeUpper();
|
s1u.MakeUpper();
|
||||||
s1l.MakeLower();
|
s1l.MakeLower();
|
||||||
|
|
||||||
|
CPPUNIT_ASSERT_EQUAL( _T("HELLO!"), s1u );
|
||||||
|
CPPUNIT_ASSERT_EQUAL( _T("hello!"), s1l );
|
||||||
|
|
||||||
wxString s2u, s2l;
|
wxString s2u, s2l;
|
||||||
s2u.MakeUpper();
|
s2u.MakeUpper();
|
||||||
s2l.MakeLower();
|
s2l.MakeLower();
|
||||||
|
|
||||||
CPPUNIT_ASSERT( s1u == _T("HELLO!") );
|
CPPUNIT_ASSERT_EQUAL( "", s2u );
|
||||||
CPPUNIT_ASSERT( s1l == _T("hello!") );
|
CPPUNIT_ASSERT_EQUAL( "", s2l );
|
||||||
CPPUNIT_ASSERT( s2u == wxEmptyString );
|
|
||||||
CPPUNIT_ASSERT( s2l == wxEmptyString );
|
|
||||||
|
wxString s3("good bye");
|
||||||
|
CPPUNIT_ASSERT_EQUAL( "Good bye", s3.Capitalize() );
|
||||||
|
s3.MakeCapitalized();
|
||||||
|
CPPUNIT_ASSERT_EQUAL( "Good bye", s3 );
|
||||||
|
|
||||||
|
CPPUNIT_ASSERT_EQUAL( "Abc", wxString("ABC").Capitalize() );
|
||||||
|
|
||||||
|
CPPUNIT_ASSERT_EQUAL( "", wxString().Capitalize() );
|
||||||
}
|
}
|
||||||
|
|
||||||
void StringTestCase::Compare()
|
void StringTestCase::Compare()
|
||||||
|
Reference in New Issue
Block a user