From e56e6df99cd89b0aa6e0bf8fda723f39ede41806 Mon Sep 17 00:00:00 2001 From: ljfa-ag Date: Tue, 14 Jul 2015 13:56:35 +0200 Subject: Add C string constructor to tag_string --- include/tag_string.h | 2 ++ src/tag_string.cpp | 10 ++++++++++ 2 files changed, 12 insertions(+) diff --git a/include/tag_string.h b/include/tag_string.h index f4476993e3..846650e507 100644 --- a/include/tag_string.h +++ b/include/tag_string.h @@ -35,6 +35,7 @@ public: tag_string(const std::string& str); tag_string(std::string&& str = ""); + tag_string(const char* str); operator std::string&(); operator const std::string&() const; @@ -42,6 +43,7 @@ public: tag_string& operator=(const std::string& str); tag_string& operator=(std::string&& str); + tag_string& operator=(const char* str); void set(const std::string& str); void set(std::string&& str); diff --git a/src/tag_string.cpp b/src/tag_string.cpp index 6bd1465e84..e4f714d0b3 100644 --- a/src/tag_string.cpp +++ b/src/tag_string.cpp @@ -30,6 +30,10 @@ tag_string::tag_string(std::string&& str): value(std::move(str)) {} +tag_string::tag_string(const char* str): + value(std::string(str)) +{} + tag_string::operator std::string&() { return value; @@ -57,6 +61,12 @@ tag_string& tag_string::operator=(std::string&& str) return *this; } +tag_string& tag_string::operator=(const char* str) +{ + value = std::string(str); + return *this; +} + void tag_string::set(const std::string& str) { value = str; -- cgit 0.0.5-2-1-g0f52