summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--raul/Symbol.hpp11
-rw-r--r--src/Symbol.cpp9
2 files changed, 10 insertions, 10 deletions
diff --git a/raul/Symbol.hpp b/raul/Symbol.hpp
index c2efbdc..469a4cf 100644
--- a/raul/Symbol.hpp
+++ b/raul/Symbol.hpp
@@ -45,7 +45,7 @@ public:
* It is a fatal error to construct a Symbol from an invalid string,
* use is_valid first to check.
*/
- Symbol(const std::basic_string<char>& symbol)
+ explicit Symbol(const std::basic_string<char>& symbol)
: _str(g_intern_string(symbol.c_str()))
{
assert(is_valid(symbol));
@@ -56,12 +56,17 @@ public:
* It is a fatal error to construct a Symbol from an invalid string,
* use is_valid first to check.
*/
- Symbol(const char* csymbol)
+ explicit Symbol(const char* csymbol)
: _str(g_intern_string(csymbol))
{
assert(is_valid(csymbol));
}
+ Symbol& operator=(const Symbol& other) {
+ _str = other._str;
+ return *this;
+ }
+
inline const char* c_str() const { return _str; }
inline bool operator==(const Symbol& other) const {
@@ -78,7 +83,7 @@ public:
static bool is_valid(const std::basic_string<char>& symbol);
- static std::string symbolify(const std::basic_string<char>& str);
+ static Raul::Symbol symbolify(const std::basic_string<char>& str);
private:
const char* _str;
diff --git a/src/Symbol.cpp b/src/Symbol.cpp
index fdaf711..4fe049e 100644
--- a/src/Symbol.cpp
+++ b/src/Symbol.cpp
@@ -53,19 +53,14 @@ Symbol::is_valid(const std::basic_string<char>& symbol)
* This will make a best effort at turning @a str into a complete, valid
* Symbol, and will always return one.
*/
-string
+Raul::Symbol
Symbol::symbolify(const std::basic_string<char>& str)
{
string symbol = str;
Path::replace_invalid_chars(symbol, 0, true);
- if (symbol.length() == 0)
- return "_";
-
- assert(is_valid(symbol));
-
- return symbol;
+ return Raul::Symbol(symbol.empty() ? "_" : symbol);
}
} // namespace Raul