فهرست منبع

Add to_string_id()

Daniele Bartolini 12 سال پیش
والد
کامیت
7f0c80a969
1فایلهای تغییر یافته به همراه10 افزوده شده و 0 حذف شده
  1. 10 0
      engine/core/strings/DynamicString.h

+ 10 - 0
engine/core/strings/DynamicString.h

@@ -33,6 +33,7 @@ OTHER DEALINGS IN THE SOFTWARE.
 #include "Allocator.h"
 #include "StringUtils.h"
 #include "List.h"
+#include "Hash.h"
 
 namespace crown
 {
@@ -77,6 +78,9 @@ public:
 	/// Returns wheterh the string ends with the given @æ s string.
 	bool				ends_with(const char* s);
 
+	/// Returns the string hashed to hash::murmur2_32.
+	StringId32			to_string_id();
+
 	///
 	const char*			c_str();
 
@@ -229,6 +233,12 @@ inline bool DynamicString::ends_with(const char* s)
 	return false;
 }
 
+//-----------------------------------------------------------------------------
+inline StringId32 DynamicString::to_string_id()
+{
+	return hash::murmur2_32(c_str(), length());
+}
+
 //-----------------------------------------------------------------------------
 inline const char* DynamicString::c_str()
 {