[libcalamares] Create namespace Calamares::String
This is a step towards getting rid of CalamaresUtils and using more structured namespaces overall, e.g. Calamares::String for things related to string-handling.
This commit is contained in:
parent
2c0d9396e2
commit
d03a8acc9d
@ -19,7 +19,9 @@
|
||||
|
||||
#include <QStringList>
|
||||
|
||||
namespace CalamaresUtils
|
||||
namespace Calamares
|
||||
{
|
||||
namespace String
|
||||
{
|
||||
QString
|
||||
removeDiacritics( const QString& string )
|
||||
@ -124,7 +126,7 @@ obscure( const QString& string )
|
||||
|
||||
|
||||
QString
|
||||
truncateMultiLine( const QString& string, CalamaresUtils::LinesStartEnd lines, CalamaresUtils::CharCount chars )
|
||||
truncateMultiLine( const QString& string, LinesStartEnd lines, CharCount chars )
|
||||
{
|
||||
const char NEWLINE = '\n';
|
||||
const int maxLines = lines.atStart + lines.atEnd;
|
||||
@ -246,4 +248,5 @@ removeTrailing( QString& string, QChar c )
|
||||
string.remove( lastIndex, string.length() );
|
||||
}
|
||||
|
||||
} // namespace CalamaresUtils
|
||||
} // namespace String
|
||||
} // namespace Calamares
|
||||
|
@ -42,10 +42,15 @@ constexpr static const auto SplitKeepEmptyParts =
|
||||
#endif
|
||||
;
|
||||
|
||||
namespace Calamares
|
||||
{
|
||||
/**
|
||||
* @brief The CalamaresUtils namespace contains utility functions.
|
||||
* @brief The Calamares::String namespace
|
||||
*
|
||||
* This namespace contains functions related to string-handling,
|
||||
* string-expansion, etc.
|
||||
*/
|
||||
namespace CalamaresUtils
|
||||
namespace String
|
||||
{
|
||||
/**
|
||||
* @brief removeDiacritics replaces letters with diacritics and ligatures with
|
||||
@ -113,6 +118,7 @@ DLLEXPORT void removeLeading( QString& string, QChar c );
|
||||
*/
|
||||
DLLEXPORT void removeTrailing( QString& string, QChar c );
|
||||
|
||||
} // namespace CalamaresUtils
|
||||
} // namespace String
|
||||
} // namespace Calamares
|
||||
|
||||
#endif
|
||||
|
@ -554,7 +554,7 @@ LibCalamaresTests::testStringTruncation()
|
||||
{
|
||||
Logger::setupLogLevel( Logger::LOGDEBUG );
|
||||
|
||||
using namespace CalamaresUtils;
|
||||
using namespace Calamares::String;
|
||||
|
||||
const QString longString( R"(---
|
||||
--- src/libcalamares/utils/String.h
|
||||
@ -635,7 +635,7 @@ LibCalamaresTests::testStringTruncationShorter()
|
||||
{
|
||||
Logger::setupLogLevel( Logger::LOGDEBUG );
|
||||
|
||||
using namespace CalamaresUtils;
|
||||
using namespace Calamares::String;
|
||||
|
||||
const QString longString( R"(Some strange string artifacts appeared, leading to `{1?}` being
|
||||
displayed in various user-facing messages. These have been removed
|
||||
@ -730,7 +730,7 @@ LibCalamaresTests::testStringTruncationDegenerate()
|
||||
{
|
||||
Logger::setupLogLevel( Logger::LOGDEBUG );
|
||||
|
||||
using namespace CalamaresUtils;
|
||||
using namespace Calamares::String;
|
||||
|
||||
// This is quite long, 1 line only, with no newlines
|
||||
const QString longString( "The portscout new distfile checker has detected that one or more of your "
|
||||
@ -783,7 +783,7 @@ LibCalamaresTests::testStringRemoveLeading()
|
||||
QFETCH( QString, result );
|
||||
|
||||
const QString initial = string;
|
||||
CalamaresUtils::removeLeading( string, c );
|
||||
Calamares::String::removeLeading( string, c );
|
||||
QCOMPARE( string, result );
|
||||
}
|
||||
|
||||
@ -813,7 +813,7 @@ LibCalamaresTests::testStringRemoveTrailing()
|
||||
QFETCH( QString, result );
|
||||
|
||||
const QString initial = string;
|
||||
CalamaresUtils::removeTrailing( string, c );
|
||||
Calamares::String::removeTrailing( string, c );
|
||||
QCOMPARE( string, result );
|
||||
}
|
||||
|
||||
@ -993,7 +993,7 @@ LibCalamaresTests::testRunnerOutput()
|
||||
|
||||
Calamares::Utils::Runner r( { "cat" } );
|
||||
r.enableOutputProcessing().setInput( QStringLiteral( "hello\nworld\n\n!\n" ) );
|
||||
QObject::connect( &r, &decltype( r )::output, [&collectedOutput]( QString s ) { collectedOutput << s; } );
|
||||
QObject::connect( &r, &decltype( r )::output, [ &collectedOutput ]( QString s ) { collectedOutput << s; } );
|
||||
|
||||
{
|
||||
auto result = r.run();
|
||||
|
Loading…
Reference in New Issue
Block a user