Skip to content

Commit 6f931d2

Browse files
add more StringBuild Functionality
1 parent f5c416c commit 6f931d2

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

src/framework/System/StringBuilder.h

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,27 @@ namespace System
5252
{
5353
m_str.Clear();
5454
}
55+
56+
/// the length of the buffer
57+
int Length()
58+
{
59+
return m_str.Length();
60+
}
61+
62+
int MaxCapacity()
63+
{
64+
// TODO there is no capacity at present
65+
return (Length()*2);
66+
}
67+
68+
int Capacity(){
69+
return MaxCapacity();
70+
}
71+
72+
char operator[](int index) const
73+
{
74+
return m_str[index];
75+
}
5576
};
5677
}
5778

src/unittests/StringBuilder_Test.cxx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,6 @@ TEST(StringBuilderTest, Creation)
1313
sb.Append("Hello");
1414

1515
EXPECT_EQ("ABCWorldHello",sb.ToString());
16+
17+
EXPECT_EQ('C',sb[2]);
1618
}

0 commit comments

Comments
 (0)