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