GCC Code Coverage Report


Directory: ./
File: tmp_project/PhoenixCore/src/convertToString_impl.h
Date: 2025-03-14 11:56:07
Exec Total Coverage
Lines: 11 11 100.0%
Branches: 6 12 50.0%

Line Branch Exec Source
1 /***************************************
2 Auteur : Pierre Aubert
3 Mail : pierre.aubert@lapp.in2p3.fr
4 Licence : CeCILL-C
5 ****************************************/
6
7 #ifndef __CONVERTTOSTRING_IMPL_H__
8 #define __CONVERTTOSTRING_IMPL_H__
9
10 #include "convertToString.h"
11 #include "PString.h"
12 #include "PPath.h"
13
14 ///Convert a type into a string
15 /** @param val : value to be converted
16 * @return converted string
17 */
18 template<typename T>
19 1505 std::string valueToString(const T & val){
20
1/2
✓ Branch 1 taken 759 times.
✗ Branch 2 not taken.
1505 std::stringstream str;
21
1/2
✓ Branch 1 taken 759 times.
✗ Branch 2 not taken.
1505 str << val;
22
1/2
✓ Branch 1 taken 759 times.
✗ Branch 2 not taken.
3010 return str.str();
23 1505 }
24
25 ///Convert a string into value
26 /** @param str : string to be converted
27 * @return converted value
28 */
29 template<typename T>
30 5 T stringToValue(const std::string & str){
31
1/2
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
5 std::stringstream strStream;
32
1/2
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
5 strStream << str;
33 T val;
34
1/2
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
5 strStream >> val;
35 5 return val;
36 5 }
37
38
39 #endif
40
41