root / branches / test / CCV_Select_Camera / libs / poco / include / CppUnit / estring.h @ 12

View | Annotate | Download (1.2 KB)

1
//
2
// estring.h
3
//
4
// $Id: //poco/1.3/CppUnit/include/CppUnit/estring.h#1 $
5
//
6
7
8
#ifndef CppUnit_estring_INCLUDED
9
#define CppUnit_estring_INCLUDED
10
11
12
#include "CppUnit/CppUnit.h"
13
#include <string>
14
#include <stdio.h>
15
16
17
namespace CppUnit {
18
19
20
// Create a std::string from a const char pointer
21
inline std::string estring(const char *cstring)
22
{
23
        return std::string(cstring);
24
}
25
26
27
// Create a std::string from a std::string (for uniformities' sake)
28
inline std::string estring(std::string& expandedString)
29
{
30
        return expandedString;
31
}
32
33
34
// Create a std::string from an int
35
inline std::string estring(int number)
36
{
37
        char buffer[50]; 
38
        sprintf(buffer, "%d", number); 
39
        return std::string (buffer); 
40
}
41
42
43
// Create a string from a long
44
inline std::string estring(long number)
45
{
46
        char buffer[50]; 
47
        sprintf(buffer, "%ld", number); 
48
        return std::string (buffer); 
49
}
50
51
52
// Create a std::string from a double
53
inline std::string estring(double number)
54
{
55
        char buffer[50]; 
56
        sprintf(buffer, "%lf", number); 
57
        return std::string(buffer);
58
}
59
60
61
// Create a std::string from a double
62
inline std::string estring(const void* ptr)
63
{
64
        char buffer[50]; 
65
        sprintf(buffer, "%p", ptr); 
66
        return std::string(buffer);
67
}
68
69
70
} // namespace CppUnit
71
72
73
#endif // CppUnit_estring_INCLUDED