|
|
@@ -32,12 +32,18 @@ struct DynamicString
|
|
|
DynamicString& operator=(const char c);
|
|
|
DynamicString& operator=(const FixedString& s);
|
|
|
|
|
|
+ /// Sets the string to @a s.
|
|
|
+ void set(const char* s, u32 len);
|
|
|
+
|
|
|
/// Reserves space for at least @n characters.
|
|
|
void reserve(u32 n);
|
|
|
|
|
|
- // Returns the length of the string.
|
|
|
+ /// Returns the length of the string.
|
|
|
u32 length() const;
|
|
|
|
|
|
+ /// Returns whether the string is empty.
|
|
|
+ bool empty() const;
|
|
|
+
|
|
|
/// Removes the leading string @a s.
|
|
|
/// @note
|
|
|
/// The string must start with @a s.
|
|
|
@@ -73,6 +79,12 @@ inline DynamicString::DynamicString(const char* s, Allocator& a)
|
|
|
array::push(_data, s, strlen32(s));
|
|
|
}
|
|
|
|
|
|
+inline void DynamicString::set(const char* s, u32 len)
|
|
|
+{
|
|
|
+ array::resize(_data, len);
|
|
|
+ strncpy(array::begin(_data), s, len);
|
|
|
+}
|
|
|
+
|
|
|
inline DynamicString& operator+=(DynamicString& a, const DynamicString& b)
|
|
|
{
|
|
|
array::push(a._data, array::begin(b._data), array::size(b._data));
|
|
|
@@ -152,6 +164,11 @@ inline u32 DynamicString::length() const
|
|
|
return strlen32(this->c_str());
|
|
|
}
|
|
|
|
|
|
+inline bool DynamicString::empty() const
|
|
|
+{
|
|
|
+ return length() == 0;
|
|
|
+}
|
|
|
+
|
|
|
inline void DynamicString::strip_leading(const char* s)
|
|
|
{
|
|
|
CE_ASSERT_NOT_NULL(s);
|