Skip to content

Commit

Permalink
added a specialization of foundation::from_string() taking a const ch…
Browse files Browse the repository at this point in the history
…ar*.
  • Loading branch information
dictoon committed Feb 7, 2014
1 parent 11aa09d commit cfac2dd
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
3 changes: 1 addition & 2 deletions src/appleseed.studio/utility/interop.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
#include <algorithm>
#include <cstddef>
#include <iostream>
#include <string>

namespace appleseed {
namespace studio {
Expand Down Expand Up @@ -143,7 +142,7 @@ namespace foundation
{

template <>
inline QString from_string(const std::string& s)
inline QString from_string(const char* s)
{
return QString::fromStdString(s);
}
Expand Down
16 changes: 12 additions & 4 deletions src/appleseed/foundation/utility/string.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ std::string to_string(
// Convert a string to a value.
template <typename T>
T from_string(const std::string& s);
template <typename T>
T from_string(const char* s);


//
Expand Down Expand Up @@ -399,6 +401,12 @@ std::string to_string(

template <typename T>
T from_string(const std::string& s)
{
return from_string<T>(s.c_str());
}

template <typename T>
T from_string(const char* s)
{
std::stringstream sstr;
sstr << s;
Expand All @@ -413,13 +421,13 @@ T from_string(const std::string& s)
}

template <>
inline std::string from_string(const std::string& s)
inline std::string from_string(const char* s)
{
return s;
}

template <>
inline bool from_string(const std::string& s)
inline bool from_string(const char* s)
{
const std::string t = lower_case(s);

Expand All @@ -431,7 +439,7 @@ inline bool from_string(const std::string& s)
}

template <>
inline int8 from_string(const std::string& s)
inline int8 from_string(const char* s)
{
std::stringstream sstr;
sstr << s;
Expand All @@ -446,7 +454,7 @@ inline int8 from_string(const std::string& s)
}

template <>
inline uint8 from_string(const std::string& s)
inline uint8 from_string(const char* s)
{
std::stringstream sstr;
sstr << s;
Expand Down

0 comments on commit cfac2dd

Please sign in to comment.