Version upgrade 4.00 #45
|
@ -2,6 +2,8 @@
|
|||
|
||||
#include "chars.h"
|
||||
|
||||
#include <QStringView>
|
||||
|
||||
|
||||
namespace StringOps
|
||||
{
|
||||
|
@ -17,6 +19,14 @@ size_t count( std::string_view str, std::string_view flag ) noexcept
|
|||
}
|
||||
|
||||
|
||||
bool isNumeric( QStringView str ) noexcept
|
||||
{
|
||||
return str.empty()
|
||||
? false
|
||||
: std::all_of( str.cbegin(), str.cend(), [](const QChar c){ return c.isDigit(); } );
|
||||
}
|
||||
|
||||
|
||||
std::string strip( const std::string& str, const char chr ) noexcept
|
||||
{
|
||||
if (const size_t start{ str.find_first_not_of( chr ) }; start != std::string::npos ) {
|
||||
|
|
|
@ -8,6 +8,9 @@
|
|||
#include <algorithm>
|
||||
|
||||
|
||||
class QStringView;
|
||||
|
||||
|
||||
//! StringOps
|
||||
/*!
|
||||
Utilities for the strings
|
||||
|
@ -15,7 +18,7 @@
|
|||
namespace StringOps
|
||||
{
|
||||
|
||||
//! Count the occurrences of the given sequence in the given string
|
||||
//! Counts the occurrences of the given sequence in the given string
|
||||
/*!
|
||||
\param str The target string
|
||||
\param flag The character to find
|
||||
|
@ -26,7 +29,7 @@ inline size_t count( std::string_view str, const char flag ) noexcept
|
|||
return static_cast<size_t>( std::count( str.cbegin(), str.cend(), flag ) );
|
||||
}
|
||||
|
||||
//! Count the occurrences of the given sequence in the given string
|
||||
//! Counts the occurrences of the given sequence in the given string
|
||||
/*!
|
||||
\param str The target string
|
||||
\param flag The string to find
|
||||
|
@ -46,6 +49,13 @@ inline bool isNumeric( std::string_view str ) noexcept
|
|||
: std::all_of( str.cbegin(), str.cend(), CharOps::isNumeric );
|
||||
}
|
||||
|
||||
//! Checks whether a string only contains numeric characters
|
||||
/*!
|
||||
\param str The target string
|
||||
\return The result of the check
|
||||
*/
|
||||
bool isNumeric( QStringView str ) noexcept;
|
||||
|
||||
//! Checks whether a string only contains alphabetic characters
|
||||
/*!
|
||||
\param str The target string
|
||||
|
|
Loading…
Reference in a new issue