sources/mystring.h

branch
protocol5
changeset 159
970d58a01e8b
parent 150
37db42ad451a
parent 158
de7574d292ad
child 195
be953e1621d9
--- a/sources/mystring.h	Wed Jul 20 18:31:19 2016 +0300
+++ b/sources/mystring.h	Fri Jul 22 17:59:55 2016 +0300
@@ -93,6 +93,7 @@
 	const std::string&          stdString() const;
 	void                        strip(char unwanted);
 	void                        strip(const List<char> &unwanted);
+	const unsigned char*        toBytes() const;
 	double                      toDouble(bool* ok = nullptr) const;
 	float                       toFloat(bool* ok = nullptr) const;
 	long                        toInt(bool* ok = nullptr, int base = 10) const;
@@ -107,6 +108,7 @@
 	static String               fromNumber(unsigned int a);
 	static String               fromNumber(unsigned long int a);
 	static String               fromNumber(double a);
+	static String               fromBytes(const ByteArray& bytes);
 
 	String                      operator+(const String& data) const;
 	String                      operator+(const char* data) const;
@@ -553,6 +555,14 @@
 }
 
 /*!
+ * \returns the underlying char-array representation of this string, casted to unsigned chars.
+ */
+inline const unsigned char* String::toBytes() const
+{
+	return reinterpret_cast<const unsigned char*>(chars());
+}
+
+/*!
  * \brief Constructs an empty string list.
  */
 inline StringList::StringList() {}

mercurial