Skip to content

Commit bee370f

Browse files
committed
#31 - Implement method CppStringT::istitle()
Completed.
1 parent 46387e1 commit bee370f

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

cpp-strings/cppstrings.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -522,6 +522,18 @@ namespace pcs // i.e. "pythonic c++ strings"
522522
}
523523

524524

525+
//--- istitle() ---------------------------------------
526+
/** \brief Returns true if the string is a titlecased string and there is at least one character, or false otherwise.
527+
*
528+
* For instance uppercase characters may only follow uncased
529+
* characters and lowercase characters only cased ones.
530+
*/
531+
inline const bool istitle() const noexcept
532+
{
533+
return !this->empty && this->title() == *this;
534+
}
535+
536+
525537
//--- is_words_sep() ----------------------------------
526538
/** \brief Returns true if there are only whitespace and punctuation characters in the string and there is at least one character, or false otherwise. */
527539
inline const bool is_words_sep() const noexcept
@@ -691,6 +703,14 @@ namespace pcs // i.e. "pythonic c++ strings"
691703
}
692704

693705

706+
//--- title() -----------------------------------------
707+
/** \brief Returns a titlecased copy of the string where words start with an uppercase character and the remaining characters are lowercase. */
708+
inline CppStringT title() const noexcept
709+
{
710+
return *this;
711+
}
712+
713+
694714
//--- upper () -----------------------------------------
695715
/** \brief In-place replaces all characters of the string with their uppercase conversion. Returns a reference to string.
696716
*

0 commit comments

Comments
 (0)