[libcalamares] Expand utility of list-logging
- Allow logging any QList type (needs explicit call in usage). - Add a DebugList inheriting from DebugListT to keep existing code that logs QStringLists. - For Calamares 3.3, consider using C++17 and class template deduction.
This commit is contained in:
parent
8f060a741f
commit
3456aabfce
@ -134,14 +134,32 @@ public:
|
|||||||
* will produce a single timestamped debug line with continuations.
|
* will produce a single timestamped debug line with continuations.
|
||||||
* Each element of the list of strings will be logged on a separate line.
|
* Each element of the list of strings will be logged on a separate line.
|
||||||
*/
|
*/
|
||||||
struct DebugList
|
/* TODO: Calamares 3.3, bump requirements to C++17, and rename
|
||||||
|
* this to DebugList, dropping the convenience-definition
|
||||||
|
* below. In C++17, class template argument deduction is
|
||||||
|
* added, so `DebugList( whatever )` determines the right
|
||||||
|
* type already (also for QStringList).
|
||||||
|
*/
|
||||||
|
template < typename T >
|
||||||
|
struct DebugListT
|
||||||
{
|
{
|
||||||
explicit DebugList( const QStringList& l )
|
using list_t = QList< T >;
|
||||||
|
|
||||||
|
explicit DebugListT( const list_t& l )
|
||||||
: list( l )
|
: list( l )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
const QStringList& list;
|
const list_t& list;
|
||||||
|
};
|
||||||
|
|
||||||
|
///@brief Convenience for QStringList, needs no template parameters
|
||||||
|
struct DebugList : public DebugListT< QString >
|
||||||
|
{
|
||||||
|
explicit DebugList( const list_t& l )
|
||||||
|
: DebugListT( l )
|
||||||
|
{
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -174,9 +192,10 @@ operator<<( QDebug& s, const DebugRow< T, U >& t )
|
|||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @brief output operator for DebugList */
|
/** @brief output operator for DebugList, assuming operator<< for T exists */
|
||||||
|
template < typename T = QString >
|
||||||
inline QDebug&
|
inline QDebug&
|
||||||
operator<<( QDebug& s, const DebugList& c )
|
operator<<( QDebug& s, const DebugListT< T >& c )
|
||||||
{
|
{
|
||||||
for ( const auto& i : c.list )
|
for ( const auto& i : c.list )
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user