src/hbcore/i18n/hbstringutil.cpp
changeset 6 c3690ec91ef8
parent 3 11d3954df52a
child 7 923ff622b8b9
equal deleted inserted replaced
5:627c4a0fd0e7 6:c3690ec91ef8
    96     \param escapeChar The escape character, for example,  '?', '*'.
    96     \param escapeChar The escape character, for example,  '?', '*'.
    97     
    97     
    98     \return If a match is found the offset within source string's
    98     \return If a match is found the offset within source string's
    99     data where the match first occurs. -1 if match is not found.
    99     data where the match first occurs. -1 if match is not found.
   100     
   100     
   101     Example
   101     Example:
   102     \snippet{unittest_hbstringutil/unittest_hbstringutil.cpp,3}
   102     \snippet{unittest_hbstringutil/unittest_hbstringutil.cpp,3}
   103  */
   103  */
   104 int HbStringUtil::matchC( const QString &strFrom, const QString &strToMatch,
   104 int HbStringUtil::matchC( const QString &strFrom, const QString &strToMatch,
   105                                     int maxLevel, Options flags,
   105                                     int maxLevel, Options flags,
   106                                     int wildChar, int wildSequenceChar, int escapeChar )
   106                                     int wildChar, int wildSequenceChar, int escapeChar )
   154     \param flags The flags that will be used. Default value is Default.
   154     \param flags The flags that will be used. Default value is Default.
   155     
   155     
   156     \return Positive if source string is greater, negative if it is less and 
   156     \return Positive if source string is greater, negative if it is less and 
   157     zero	if the content of both strings match.
   157     zero	if the content of both strings match.
   158     
   158     
   159     Example
   159     Example:
   160     \snippet{unittest_hbstringutil/unittest_hbstringutil.cpp,1}
   160     \snippet{unittest_hbstringutil/unittest_hbstringutil.cpp,1}
   161  */
   161  */
   162 int HbStringUtil::compareC( const QString &string1, const QString &string2,
   162 int HbStringUtil::compareC( const QString &string1, const QString &string2,
   163                                         int maxLevel, Options flags )
   163                                         int maxLevel, Options flags )
   164 {
   164 {
   183     return string1.localeAwareCompare( string2 );
   183     return string1.localeAwareCompare( string2 );
   184 #endif    
   184 #endif    
   185 }
   185 }
   186 
   186 
   187 /*!
   187 /*!
   188     Searches for the first occurence of the specified collated 
   188     Searches for the first occurrence of the specified collated 
   189     data sequence in the aStrFrom to the specified maximum
   189     data sequence in the aStrFrom to the specified maximum
   190     collation level.
   190     collation level.
   191     
   191     
   192     \attention Cross-Platform API
   192     \attention Cross-Platform API
   193     
   193     
   200     Level 3 - Character identity, accents, case and Unicode value; 
   200     Level 3 - Character identity, accents, case and Unicode value; 
   201     
   201     
   202     \return Offset of the data sequence from the beginning of the
   202     \return Offset of the data sequence from the beginning of the
   203     aStrFrom. -1 if the data sequence cannot be found.
   203     aStrFrom. -1 if the data sequence cannot be found.
   204     
   204     
   205     Example
   205     Example:
   206     \snippet{unittest_hbstringutil/unittest_hbstringutil.cpp,5}
   206     \snippet{unittest_hbstringutil/unittest_hbstringutil.cpp,5}
   207  */
   207  */
   208 int HbStringUtil::findC( const QString &strFrom,
   208 int HbStringUtil::findC( const QString &strFrom,
   209                          const QString &strToFind,
   209                          const QString &strToFind,
   210                          int           maxLevel )
   210                          int           maxLevel )
   235     \param strToMatch Pattern string.
   235     \param strToMatch Pattern string.
   236     
   236     
   237     \return If a match is found the offset within source string's
   237     \return If a match is found the offset within source string's
   238     data where the match first occurs. -1 if match is not found.
   238     data where the match first occurs. -1 if match is not found.
   239     
   239     
   240     Example
   240     Example:
   241     \snippet{unittest_hbstringutil/unittest_hbstringutil.cpp,4}
   241     \snippet{unittest_hbstringutil/unittest_hbstringutil.cpp,4}
   242  */
   242  */
   243 int HbStringUtil::matchF( const QString &strFrom,
   243 int HbStringUtil::matchF( const QString &strFrom,
   244                           const QString &strToMatch )
   244                           const QString &strToMatch )
   245 {
   245 {
   259     
   259     
   260 #endif      
   260 #endif      
   261 }
   261 }
   262 
   262 
   263 /*!
   263 /*!
   264     Searches for the first occurence of the specified folded 
   264     Searches for the first occurrence of the specified folded 
   265     data sequence in the strFrom.
   265     data sequence in the strFrom.
   266     
   266     
   267     \attention Cross-Platform API
   267     \attention Cross-Platform API
   268     
   268     
   269     \param strFrom Source string.
   269     \param strFrom Source string.
   271     
   271     
   272     \return Offset of the data sequence from the beginning of the
   272     \return Offset of the data sequence from the beginning of the
   273     strFrom. -1 if the data sequence cannot be found. Zero,
   273     strFrom. -1 if the data sequence cannot be found. Zero,
   274     if the length of search data sequence is zero.
   274     if the length of search data sequence is zero.
   275     
   275     
   276     Example
   276     Example:
   277     \snippet{unittest_hbstringutil/unittest_hbstringutil.cpp,6}
   277     \snippet{unittest_hbstringutil/unittest_hbstringutil.cpp,6}
   278  */
   278  */
   279 int HbStringUtil::findF( const QString &strFrom,
   279 int HbStringUtil::findF( const QString &strFrom,
   280                          const QString &strToFind )
   280                          const QString &strToFind )
   281 {
   281 {
   299     \param string2 String whose data is to be compared with the source string.
   299     \param string2 String whose data is to be compared with the source string.
   300     
   300     
   301     \return Positive if source string is greater, negative if it is less and 
   301     \return Positive if source string is greater, negative if it is less and 
   302     zero if the content of both strings match.
   302     zero if the content of both strings match.
   303     
   303     
   304     Example
   304     Example:
   305     \snippet{unittest_hbstringutil/unittest_hbstringutil.cpp,2}
   305     \snippet{unittest_hbstringutil/unittest_hbstringutil.cpp,2}
   306  */
   306  */
   307 int HbStringUtil::compareF( const QString &string1,
   307 int HbStringUtil::compareF( const QString &string1,
   308                             const QString &string2 )
   308                             const QString &string2 )
   309 {
   309 {
   345 {
   345 {
   346 	HbExtendedLocale locale = HbExtendedLocale::system();
   346 	HbExtendedLocale locale = HbExtendedLocale::system();
   347 	DigitType digitType = WesternDigit;
   347 	DigitType digitType = WesternDigit;
   348 	if (locale.language() == HbExtendedLocale::Arabic) {
   348 	if (locale.language() == HbExtendedLocale::Arabic) {
   349 		digitType = ArabicIndicDigit;
   349 		digitType = ArabicIndicDigit;
   350 	}
   350 	} else if (locale.language() == HbExtendedLocale::Persian || locale.language() == HbExtendedLocale::Urdu) {
   351 	if (locale.language() == HbExtendedLocale::Persian) {
       
   352 		digitType = EasternArabicIndicDigit;
       
   353 	}
       
   354 	if (locale.language() == HbExtendedLocale::Urdu) {
       
   355 		digitType = EasternArabicIndicDigit;
   351 		digitType = EasternArabicIndicDigit;
   356 	}
   352 	}
   357 	QString converted = HbStringUtil::convertDigitsTo(str, digitType);
   353 	QString converted = HbStringUtil::convertDigitsTo(str, digitType);
   358 	return converted;
   354 	return converted;
   359 }
   355 }
   398     
   394     
   399     \attention Cross-Platform API
   395     \attention Cross-Platform API
   400     
   396     
   401     \param strList List of QStrings which need to be sorted.
   397     \param strList List of QStrings which need to be sorted.
   402     
   398     
   403     Example
   399     Example:
   404     \snippet{unittest_hbstringutil/unittest_hbstringutil.cpp,7}
   400     \snippet{unittest_hbstringutil/unittest_hbstringutil.cpp,7}
   405  */
   401  */
   406 void HbStringUtil::sort( QStringList &strList )
   402 void HbStringUtil::sort( QStringList &strList )
   407 {
   403 {
   408 	if ( strList.size() > 1 ) {
   404 	if ( strList.size() > 1 ) {