Skip to content
This repository has been archived by the owner on Sep 4, 2021. It is now read-only.

Commit

Permalink
[util] support for cor::Record debug tracing
Browse files Browse the repository at this point in the history
Signed-off-by: Denis Zalevskiy <denis.zalevskiy@jolla.com>
  • Loading branch information
Denis Zalevskiy committed May 28, 2015
1 parent 2a69d3f commit 1f81589
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions include/qtaround/util.hpp
Expand Up @@ -8,6 +8,7 @@
* @par License: LGPL 2.1 http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html
*/

#include <cor/util.hpp>
#include "error.hpp"

#include <QVariant>
Expand Down Expand Up @@ -164,8 +165,10 @@ T unbox(std::unique_ptr<T> p)
return std::move(*p);
}

/// deprecated
template <typename T> struct StructTraits;

/// deprecated
template <typename FieldsT>
struct Struct
{
Expand Down Expand Up @@ -215,6 +218,7 @@ constexpr size_t count(Args &&...)
return sizeof...(Args);
}

/// deprecated
#define STRUCT_NAMES(Id, id_names...) \
template <Id i> \
static char const * name() \
Expand All @@ -227,6 +231,7 @@ constexpr size_t count(Args &&...)

namespace qtaround { namespace debug {

/// deprecated
template <size_t N>
struct StructDump
{
Expand All @@ -242,6 +247,7 @@ struct StructDump
}
};

/// deprecated
template <>
struct StructDump<1>
{
Expand All @@ -256,6 +262,7 @@ struct StructDump<1>
}
};

/// deprecated
template <typename FieldsT>
QDebug & operator <<(QDebug &d, Struct<FieldsT> const &v)
{
Expand All @@ -267,6 +274,23 @@ QDebug & operator <<(QDebug &d, Struct<FieldsT> const &v)

}}

template <typename FieldsT, typename... ElementsT>
QDebug & operator <<(QDebug &dst, Record<FieldsT, ElementsT...> const &v)
{
static constexpr auto index = static_cast<size_t>(FieldsT::Last_);
dst << "("; RecordDump<index>::out(dst, v); dst << ")";
return dst;
}

template <typename FieldsT, typename... ElementsT>
QString loggable(Record<FieldsT, ElementsT...> const &v)
{
QString res;
QDebug dst(res);
dst << v;
return res;
}

namespace qtaround { namespace util {

template <typename ResT, typename T, typename FnT>
Expand Down

0 comments on commit 1f81589

Please sign in to comment.