GCC Code Coverage Report


Directory: ./
File: tmp_project/PhoenixString/src/convertToString_impl.h
Date: 2024-07-27 10:53:27
Exec Total Coverage
Lines: 11 11 100.0%
Branches: 6 9 66.7%

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
12 ///Convert a type into a string
13 /** @param val : value to be converted
14 * @return converted string
15 */
16 template<typename T>
17 61 std::string convertToString(const T & val){
18
1/2
✓ Branch 1 taken 37 times.
✗ Branch 2 not taken.
61 std::stringstream str;
19
1/2
✓ Branch 1 taken 37 times.
✗ Branch 2 not taken.
61 str << val;
20
1/2
✓ Branch 1 taken 37 times.
✗ Branch 2 not taken.
122 return str.str();
21 61 }
22
23 ///Convert a string into value
24 /** @param str : string to be converted
25 * @return converted value
26 */
27 template<typename T>
28 3 T stringToValue(const std::string & str){
29
1/1
✓ Branch 1 taken 3 times.
3 std::stringstream strStream;
30
1/1
✓ Branch 1 taken 3 times.
3 strStream << str;
31 T val;
32
1/1
✓ Branch 1 taken 3 times.
3 strStream >> val;
33 3 return val;
34 3 }
35
36
37 #endif
38
39