Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:12:43

0001 #ifndef ERROROBJ_ICC
0002 #error ErrorObj.icc erroneously included by file other than ErrorObj.h
0003 #endif
0004 
0005 // ----------------------------------------------------------------------
0006 //
0007 // ErrorObj.icc
0008 //
0009 // 3/20/06  mf      Instrumented for universal suppression of spaces
0010 //          (that is, items no longer contain any space added
0011 //          by the MessageLogger stack)
0012 
0013 // ----------------------------------------------------------------------
0014 
0015 #include <sstream>
0016 
0017 #include "fmt/ostream.h"
0018 
0019 namespace edm {
0020 
0021   // ----------------------------------------------------------------------
0022   // Methods for physicists adding to an ErrorObj:
0023   // ----------------------------------------------------------------------
0024 
0025   template <class T>
0026   ErrorObj& ErrorObj::opltlt(const T& t) {
0027     myOs.str(emptyString);
0028     myOs << t;
0029 #ifdef OLD_STYLE_AUTOMATIC_SPACES
0030     if (!myOs.str().empty())
0031       emitToken(myOs.str() + ' ');
0032 #else
0033     if (!myOs.str().empty())
0034       emitToken(myOs.str());
0035 #endif
0036     return *this;
0037   }  // operator<< <T>()
0038 
0039   // ----------------------------------------------------------------------
0040   // Global method for physicists adding to an ErrorObj:
0041   // ----------------------------------------------------------------------
0042 
0043   template <class T>
0044   ErrorObj& operator<<(ErrorObj& e, const T& t) {
0045     return e.opltlt(t);
0046   }  // operator<< <T>()
0047 
0048   inline ErrorObj& ErrorObj::operator<<(std::ostream& (*f)(std::ostream&)) {
0049     f(myOs);
0050     myOs.str(emptyString);
0051     return *this;
0052   }
0053 
0054   inline ErrorObj& ErrorObj::operator<<(std::ios_base& (*f)(std::ios_base&)) {
0055     f(myOs);
0056     return *this;
0057   }
0058 
0059   template <typename... Args>
0060   inline ErrorObj& ErrorObj::format(fmt::format_string<Args...> format, Args&&... args) {
0061     auto str = fmt::format(std::move(format), std::forward<Args>(args)...);
0062     if (!str.empty())
0063       emitToken(str);
0064     return *this;
0065   }
0066 
0067   inline ErrorObj& ErrorObj::vformat(std::string_view format, fmt::format_args args) {
0068     auto str = fmt::vformat(format, args);
0069     if (!str.empty())
0070       emitToken(str);
0071     return *this;
0072   }
0073 
0074   // ----------------------------------------------------------------------
0075 
0076 }  // end of namespace edm