Last change
on this file since 139 was
88,
checked in by rosiere, 16 years ago
|
Almost complete design
with Test and test platform
|
-
Property svn:keywords set to
Id
|
File size:
974 bytes
|
Rev | Line | |
---|
[88] | 1 | #ifndef Morpheo_FromString_h |
---|
| 2 | #define Morpheo_FromString_h |
---|
[15] | 3 | |
---|
| 4 | /* |
---|
| 5 | * $Id: FromString.h 88 2008-12-10 18:31:39Z rosiere $ |
---|
| 6 | * |
---|
| 7 | * [ Description ] |
---|
| 8 | * |
---|
| 9 | */ |
---|
| 10 | |
---|
| 11 | // #include <iosfwd> |
---|
| 12 | // #include <sstream> |
---|
| 13 | // #include <iomanip> |
---|
| 14 | #include <string> |
---|
| 15 | // #include <limits> |
---|
| 16 | |
---|
| 17 | namespace morpheo { |
---|
| 18 | |
---|
[78] | 19 | template<typename T> inline T fromString (const std::string& x) |
---|
[15] | 20 | { |
---|
| 21 | return static_cast<T>(x.c_str()); |
---|
| 22 | } |
---|
| 23 | |
---|
[78] | 24 | template<> inline uint32_t fromString<uint32_t> (const std::string& x) |
---|
[15] | 25 | { |
---|
[78] | 26 | return static_cast<uint32_t>(atoi(x.c_str())); |
---|
[15] | 27 | } |
---|
[78] | 28 | |
---|
[88] | 29 | template<> inline uint64_t fromString<uint64_t> (const std::string& x) |
---|
| 30 | { |
---|
| 31 | return static_cast<uint64_t>(atoll(x.c_str())); |
---|
| 32 | } |
---|
| 33 | |
---|
| 34 | template<> inline double fromString<double> (const std::string& x) |
---|
| 35 | { |
---|
| 36 | return static_cast<double>(atof(x.c_str())); |
---|
| 37 | } |
---|
| 38 | |
---|
[78] | 39 | template<> inline bool fromString<bool> (const std::string& x) |
---|
| 40 | { |
---|
| 41 | return atoi(x.c_str())!=0; |
---|
| 42 | } |
---|
[15] | 43 | |
---|
| 44 | }; // end namespace morpheo |
---|
| 45 | |
---|
| 46 | #endif |
---|
Note: See
TracBrowser
for help on using the repository browser.