Jelajahi Sumber

String: Added STL compatible append. Added getCPtr().

Бранимир Караџић 6 tahun lalu
induk
melakukan
4ecfa36057
2 mengubah file dengan 19 tambahan dan 0 penghapusan
  1. 12 0
      include/bx/inline/string.inl
  2. 7 0
      include/bx/string.h

+ 12 - 0
include/bx/inline/string.inl

@@ -225,6 +225,12 @@ namespace bx
 		}
 	}
 
+	template<bx::AllocatorI** AllocatorT>
+	inline void StringT<AllocatorT>::append(const char* _ptr, const char* _term)
+	{
+		append(StringView(_ptr, _term) );
+	}
+
 	template<bx::AllocatorI** AllocatorT>
 	inline void StringT<AllocatorT>::clear()
 	{
@@ -236,6 +242,12 @@ namespace bx
 		}
 	}
 
+	template<bx::AllocatorI** AllocatorT>
+	inline const char* StringT<AllocatorT>::getCPtr() const
+	{
+		return getPtr();
+	}
+
 	inline StringView strSubstr(const StringView& _str, int32_t _start, int32_t _len)
 	{
 		return StringView(_str, _start, _len);

+ 7 - 0
include/bx/string.h

@@ -128,8 +128,15 @@ namespace bx
 		///
 		void append(const StringView& _str);
 
+		///
+		void append(const char* _ptr, const char* _term);
+
 		///
 		void clear();
+
+		/// Returns zero-terminated C string pointer.
+		///
+		const char* getCPtr() const;
 	};
 
 	/// Retruns true if character is part of space set.