Bläddra i källkod

Result DBO print helper method

develop
Robin Thoni 9 år sedan
förälder
incheckning
91024e1250
2 ändrade filer med 9 tillägg och 0 borttagningar
  1. 2
    0
      src/DBO/Result.h
  2. 7
    0
      src/DBO/Result.hxx

+ 2
- 0
src/DBO/Result.h Visa fil

27
     template<class U>
27
     template<class U>
28
     friend std::ostream& operator<<(std::ostream& os, const Result<U>& res);
28
     friend std::ostream& operator<<(std::ostream& os, const Result<U>& res);
29
 
29
 
30
+    const Result<T>& print() const;
31
+
30
 private:
32
 private:
31
     Result();
33
     Result();
32
 
34
 

+ 7
- 0
src/DBO/Result.hxx Visa fil

88
         os << "Error: " << (res._error.empty() ? "Unknown error" : res._error);
88
         os << "Error: " << (res._error.empty() ? "Unknown error" : res._error);
89
     }
89
     }
90
     return os;
90
     return os;
91
+}
92
+
93
+template<class T>
94
+const Result<T>& Result<T>::print() const
95
+{
96
+    (_success ? std::cout : std::cerr) << *this << std::endl;
97
+    return *this;
91
 }
98
 }

Laddar…
Avbryt
Spara