char ImmutableString::charAt(int index) { if ((index < 0) || (index >= m_pProxy->count)) { throw StringIndexOutOfBoundsException(index); } return m_pProxy->value[index + m_pProxy->offset]; }
ImmutableString::ImmutableString(char *str) { if(str==NULL || strlen(str)<1) throw StringIndexOutOfBoundsException(-1); m_pProxy = new StringProxy(str); AddRef(); }
utf16string utf16string::substring(int beginIndex, int endIndex) const { //UTF16 try { std::u16string sub = m_data->u16str().substr(beginIndex, endIndex - beginIndex); utf16string answer; answer.setData(new StringData(sub)); return answer; } catch (std::out_of_range &e) { throw StringIndexOutOfBoundsException(e.what()); } }
wchar SString::operator[](int i) const{ if (i >= len) throw StringIndexOutOfBoundsException(SString(i)); return wstr[i]; }