16#ifndef LIB_ERROR_HELPER_H_ 
   17#define LIB_ERROR_HELPER_H_ 
   21#include <boost/format.hpp> 
   23#include "lib/error_message.h" 
   24#include "lib/source_file.h" 
   25#include "lib/stringify.h" 
   36template <
class... Args>
 
   37auto error_helper(boost::format &f, 
ErrorMessage out, 
const char *t, Args &&...args) {
 
   38    return error_helper(f % t, out, std::forward<Args>(args)...);
 
   41template <
typename T, 
class... Args>
 
   42auto error_helper(boost::format &f, 
ErrorMessage out, 
const T &t,
 
   43                  Args &&...args) -> std::enable_if_t<Util::has_toString_v<T>, 
ErrorMessage>;
 
   45template <
typename T, 
class... Args>
 
   46auto error_helper(boost::format &f, 
ErrorMessage out, 
const T &t, Args &&...args)
 
   47    -> std::enable_if_t<!Util::has_toString_v<T> && !std::is_pointer_v<T>, 
ErrorMessage>;
 
   49template <
typename T, 
class... Args>
 
   50auto error_helper(boost::format &f, 
ErrorMessage out, 
const T *t, Args &&...args) {
 
   54    return error_helper(f, out, *t, std::forward<Args>(args)...);
 
   57template <
class... Args>
 
   60    if (info.isValid()) out.
locations.push_back(info);
 
   61    return error_helper(f % 
"", std::move(out), std::forward<Args>(args)...);
 
   66    if constexpr (Util::has_SourceInfo_v<T>) {
 
   67        auto info = t.getSourceInfo();
 
   68        if (info.isValid()) out.
locations.push_back(info);
 
   72template <
typename T, 
class... Args>
 
   73auto error_helper(boost::format &f, 
ErrorMessage out, 
const T &t, Args &&...args)
 
   74    -> std::enable_if_t<!Util::has_toString_v<T> && !std::is_pointer_v<T>, 
ErrorMessage> {
 
   75    maybeAddSourceInfo(out, t);
 
   76    return error_helper(f % t, std::move(out), std::forward<Args>(args)...);
 
   79template <
typename T, 
class... Args>
 
   80auto error_helper(boost::format &f, 
ErrorMessage out, 
const T &t,
 
   81                  Args &&...args) -> std::enable_if_t<Util::has_toString_v<T>, 
ErrorMessage> {
 
   82    maybeAddSourceInfo(out, t);
 
   83    return error_helper(f % t.toString(), std::move(out), std::forward<Args>(args)...);
 
   89template <
class... Args>
 
   90ErrorMessage error_helper(boost::format &f, Args &&...args) {
 
   92    return ::priv::error_helper(f, msg, std::forward<Args>(args)...);
 
   96template <
class... Args>
 
   98    return ::priv::error_helper(f, std::move(msg), std::forward<Args>(args)...);
 
  102template <
class... Args>
 
  104                          const std::string &suffix, Args &&...args) {
 
  105    return ::priv::error_helper(f, 
ErrorMessage(prefix, info, suffix), std::forward<Args>(args)...);
 
Definition source_file.h:123
 
Definition error_message.h:36
 
std::vector< Util::SourceInfo > locations
Particular formatted message.
Definition error_message.h:42
 
std::string message
Typically error/warning type from catalog.
Definition error_message.h:41