test_return_value = TET_PASS;
}
+int UtcDaliTextGetImplementation01(void)
+{
+ TestApplication application;
+
+ Text text( std::string( "Hello world" ) );
+
+ const Internal::Text& textImpl1 = text.GetImplementation();
+
+ DALI_TEST_CHECK( NULL != &textImpl1 );
+
+ Internal::Text& textImpl2 = text.GetImplementation();
+
+ DALI_TEST_CHECK( NULL != &textImpl2 );
+
+ END_TEST;
+}
-int UtcDaliTextGetImplementation(void)
+int UtcDaliTextGetImplementation02(void)
{
TestApplication application;
}
END_TEST;
}
+
+int UtcDaliTextGetTextArray(void)
+{
+ TestApplication application;
+
+ Text text( std::string( "Hello world" ) );
+
+ DALI_TEST_EQUALS( text.GetImplementation().GetTextArray().size(), 11u, TEST_LOCATION );
+
+ END_TEST;
+}
DALI_TEST_CHECK(!text[8].IsNewLine()); // 'f'
END_TEST;
}
+
+int UtcDaliCharacterGetImplementation(void)
+{
+ TestApplication application;
+
+ Text text( std::string( "Hello world" ) );
+ Character c = text[0];
+
+ const Internal::Character& characterImpl1 = c.GetImplementation();
+
+ DALI_TEST_CHECK( NULL != &characterImpl1 );
+
+ Internal::Character& characterImpl2 = c.GetImplementation();
+
+ DALI_TEST_CHECK( NULL != &characterImpl2 );
+
+ END_TEST;
+}
DALI_TEST_CHECK( !someText.IsEmpty() );
+ Text someEmptyText( std::string( "" ) );
+
+ DALI_TEST_CHECK( someEmptyText.IsEmpty() );
+
+ Text someText2( Text( std::string( "Some text" ) ) );
+
+ DALI_TEST_CHECK( !someText2.IsEmpty() );
+
+ Text someEmptyText2( text );
+
+ DALI_TEST_CHECK( someEmptyText2.IsEmpty() );
+
Character c = someText[0];
Text cText( c );
Text someText4;
- printf(" is text empty ? ...... %d \n", someText4.IsEmpty());
// check for assignment of empty text
someText2 = someText4;
DALI_TEST_CHECK( someText2.IsEmpty() );
{
TestApplication application;
- const std::string someText( "Some text");
+ const std::string someText( "Some text" );
+ const std::string someText2( "Some text2" );
Text text;
text.SetText( someText );
- DALI_TEST_CHECK( someText == text.GetText() );
+ DALI_TEST_EQUALS( someText, text.GetText(), TEST_LOCATION );
+
+ text.SetText( someText2 );
+
+ DALI_TEST_EQUALS( someText2, text.GetText(), TEST_LOCATION );
Character c = text[0];
text.SetText( c );
- DALI_TEST_CHECK( std::string("S") == text.GetText() );
+ DALI_TEST_EQUALS( std::string( "S" ), text.GetText(), TEST_LOCATION );
Text text2;
text2.SetText( text );
- DALI_TEST_CHECK( text2.GetText() == text.GetText() );
+ DALI_TEST_EQUALS( text2.GetText(), text.GetText(), TEST_LOCATION );
+
END_TEST;
}
emptyText.Append( text2 );
DALI_TEST_CHECK( text2.GetText() == emptyText.GetText() );
+ // append a null text
+
+ Text emptyText2;
+ emptyText.Append( emptyText2 );
+ DALI_TEST_CHECK( text2.GetText() == emptyText.GetText() );
+
END_TEST;
}
bool assert1 = false;
bool assert2 = false;
+ bool assert3 = false;
+
try
{
text.Remove( 100, 3 );
assert2 = true;
}
- if( assert1 && assert2 )
+ try
+ {
+ text.SetText( std::string( "" ) );
+ text.Remove( 1, 300 );
+ }
+ catch( DaliException& e )
+ {
+ tet_printf( "Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str() );
+ DALI_TEST_EQUALS( e.mCondition, "NULL != mImpl && \"Text::Remove: Text is uninitialized\"", TEST_LOCATION );
+ assert3 = true;
+ }
+
+ if( assert1 && assert2 && assert3 )
{
tet_result( TET_PASS );
}
Text text01( std::string( "Some text") );
Text text02( std::string( "Somext") );
- Text text03( std::string( "") );
+ Text text03( std::string( "" ) );
+ Text text04( std::string( "Hello world" ) );
+ Text text05( std::string( "world" ) );
+
+ text01.Remove( 3u, 3u );
- text01.Remove( 3, 3 );
+ DALI_TEST_EQUALS( text01.GetLength(), text02.GetLength(), TEST_LOCATION );
+ DALI_TEST_EQUALS( text01.GetText(), text02.GetText(), TEST_LOCATION );
+
+ text01.Remove( 0u, 0u );
DALI_TEST_EQUALS( text01.GetLength(), text02.GetLength(), TEST_LOCATION );
DALI_TEST_EQUALS( text01.GetText(), text02.GetText(), TEST_LOCATION );
- text01.Remove( 0, 6 );
+ text01.Remove( 0u, 6u );
DALI_TEST_EQUALS( text01.GetLength(), text03.GetLength(), TEST_LOCATION );
DALI_TEST_EQUALS( text01.GetText(), text03.GetText(), TEST_LOCATION );
+
+ text04.Remove( 0u, 6u );
+
+ DALI_TEST_EQUALS( text04.GetLength(), text05.GetLength(), TEST_LOCATION );
+ DALI_TEST_EQUALS( text04.GetText(), text05.GetText(), TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliTextFind(void)
+{
+ TestApplication application;
+
+ Text text;
+ Character c1 = Text( std::string( "c" ) )[0u];
+ Character c2 = Text( std::string( "o" ) )[0u];
+ Vector<std::size_t> positions;
+
+ // Find in void text.
+
+ positions.Clear();
+ text.Find( c1, 0u, 0u, positions );
+ DALI_TEST_EQUALS( positions.Count(), 0u, TEST_LOCATION );
+
+ positions.Clear();
+ text.Find( Text::WHITE_SPACE, 0u, 0u, positions );
+ DALI_TEST_EQUALS( positions.Count(), 0u, TEST_LOCATION );
+
+ positions.Clear();
+ text.Find( Text::NEW_LINE, 0u, 0u, positions );
+ DALI_TEST_EQUALS( positions.Count(), 0u, TEST_LOCATION );
+
+ // Find in text.
+
+ // Find 'c' and 'o'
+ text.SetText( std::string( "Hello world" ) );
+
+ positions.Clear();
+ text.Find( c1, 0u, 11u, positions );
+ DALI_TEST_EQUALS( positions.Count(), 0u, TEST_LOCATION );
+
+ positions.Clear();
+ text.Find( c2, 0u, 11u, positions );
+ DALI_TEST_EQUALS( positions.Count(), 2u, TEST_LOCATION );
+ DALI_TEST_EQUALS( positions[0u], 4u, TEST_LOCATION );
+ DALI_TEST_EQUALS( positions[1u], 7u, TEST_LOCATION );
+
+ // Find white space
+ text.SetText( std::string( " Hello world \n" ) );
+
+ positions.Clear();
+ text.Find( Text::WHITE_SPACE, 0u, 17u, positions );
+ DALI_TEST_EQUALS( positions.Count(), 8u, TEST_LOCATION );
+ DALI_TEST_EQUALS( positions[0u], 0u, TEST_LOCATION );
+ DALI_TEST_EQUALS( positions[1u], 1u, TEST_LOCATION );
+ DALI_TEST_EQUALS( positions[2u], 2u, TEST_LOCATION );
+ DALI_TEST_EQUALS( positions[3u], 8u, TEST_LOCATION );
+ DALI_TEST_EQUALS( positions[4u], 9u, TEST_LOCATION );
+ DALI_TEST_EQUALS( positions[5u], 15u, TEST_LOCATION );
+ DALI_TEST_EQUALS( positions[6u], 16u, TEST_LOCATION );
+ DALI_TEST_EQUALS( positions[7u], 17u, TEST_LOCATION );
+
+ // Find new line character
+ text.SetText( std::string( "\n\nHello\nworld\n\n" ) );
+
+ positions.Clear();
+ text.Find( Text::NEW_LINE, 0u, 14u, positions );
+ DALI_TEST_EQUALS( positions.Count(), 5u, TEST_LOCATION );
+ DALI_TEST_EQUALS( positions[0u], 0u, TEST_LOCATION );
+ DALI_TEST_EQUALS( positions[1u], 1u, TEST_LOCATION );
+ DALI_TEST_EQUALS( positions[2u], 7u, TEST_LOCATION );
+ DALI_TEST_EQUALS( positions[3u], 13u, TEST_LOCATION );
+ DALI_TEST_EQUALS( positions[4u], 14u, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliTextGetSubText(void)
+{
+ TestApplication application;
+
+ Text text;
+ Text subText;
+
+ // Get sub-text from a void text.
+
+ subText.SetText( "Hello" );
+ text.GetSubText( 0u, 1u, subText );
+ DALI_TEST_EQUALS( subText.GetText(), std::string( "Hello" ), TEST_LOCATION );
+
+ // Get sub-text.
+
+ text.SetText( std::string( "Hello world" ) );
+
+ // Access out of bounds
+ subText.SetText( "Hello" );
+ text.GetSubText( 30u, 31u, subText );
+ DALI_TEST_EQUALS( subText.GetText(), std::string( "Hello" ), TEST_LOCATION );
+ text.GetSubText( 0u, 31u, subText );
+ DALI_TEST_EQUALS( subText.GetText(), std::string( "Hello" ), TEST_LOCATION );
+ text.GetSubText( 30u, 1u, subText );
+ DALI_TEST_EQUALS( subText.GetText(), std::string( "Hello" ), TEST_LOCATION );
+
+ // Check it swaps the indices.
+ text.GetSubText( 8u, 2u, subText );
+ DALI_TEST_EQUALS( subText.GetText(), std::string( "row oll" ), TEST_LOCATION );
+
+ // Normal access.
+ subText.SetText( std::string( "" ) );
+ text.GetSubText( 4u, 6u, subText );
+ DALI_TEST_EQUALS( subText.GetText(), std::string( "o w" ), TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliTextIsWhiteSpaceNewLine(void)
+{
+ TestApplication application;
+
+ Text text;
+
+ // Query a void text.
+
+ DALI_TEST_CHECK( !text.IsWhiteSpace( 0u ) );
+ DALI_TEST_CHECK( !text.IsNewLine( 0u ) );
+
+ // Set a text
+ text.SetText( "Hello world\n" );
+
+ // Query out of bounds
+
+ DALI_TEST_CHECK( !text.IsWhiteSpace( 30u ) );
+ DALI_TEST_CHECK( !text.IsNewLine( 30u ) );
+
+ // Normal query.
+
+ DALI_TEST_CHECK( !text.IsWhiteSpace( 1u ) );
+ DALI_TEST_CHECK( !text.IsNewLine( 1u ) );
+ DALI_TEST_CHECK( text.IsWhiteSpace( 5u ) );
+ DALI_TEST_CHECK( text.IsNewLine( 11u ) );
+
END_TEST;
}
// INTERNAL INCLUDES
#include <dali/public-api/common/dali-common.h>
#include <dali/public-api/text/character.h>
+#include <dali/public-api/common/dali-vector.h>
namespace Dali DALI_IMPORT_API
{
*/
class Text
{
+
+public:
+
+ /**
+ * @brief Enums special characters used to find their positions inside the text.
+ */
+ enum SpecialCharacter
+ {
+ WHITE_SPACE,
+ NEW_LINE
+ };
+
public:
/**
*/
void Remove( size_t position, size_t numberOfCharacters );
+ /**
+ * @brief Finds all the positions of the given \e character within the \e from, \e to range.
+ *
+ * @param[in] character The character to find.
+ * @param[in] from First position of the range.
+ * @param[in] to Last position of the range.
+ * @param[out] positions Contains all the positions of \e character within the \e from, \e to range.
+ */
+ void Find( const Character& character, std::size_t from, std::size_t to, Vector<std::size_t>& positions ) const;
+
+ /**
+ * @brief Finds all the positions of either white space or new line character within the \e from, \e to range.
+ *
+ * @param[in] character One of white space or new line.
+ * @param[in] from First position of the range.
+ * @param[in] to Last position of the range.
+ * @param[out] positions Contains all the positions of \e character within the \e from, \e to range.
+ *
+ */
+ void Find( SpecialCharacter character, std::size_t from, std::size_t to, Vector<std::size_t>& positions ) const;
+
+ /**
+ * @brief Retrieves a subtext withing the \e from, \e to range.
+ *
+ * If \e to is smaller than \e from, sub-text will be reversed.
+ *
+ * @note \e subText will be untouched if current text is not initialized of the range \e from, \e to is out of bounds.
+ *
+ * @param[in] from First position of the range.
+ * @param[in] to Last position of the range.
+ * @param[out] subText The subtext.
+ */
+ void GetSubText( std::size_t from, std::size_t to, Text& subText ) const;
+
+ /**
+ * @brief Whether the character in the \e index position is a white space.
+ *
+ * @param[in] index position of the character.
+ *
+ * @return \e true if the character pointed by \e index is a white space
+ */
+ bool IsWhiteSpace( std::size_t index ) const;
+
+ /**
+ * @brief Whether the character in the \e index position is a new line character.
+ *
+ * @param[in] index position of the character.
+ *
+ * @return \e true if the character pointed by \e index is a new line character.
+ */
+ bool IsNewLine( std::size_t index ) const;
+
private:
Internal::Text* mImpl; ///< Pointer to implementation object
// HEADER CLASS
#include <dali/internal/event/text/character-impl.h>
-// INTERNAL INCLUDES
namespace
{
namespace Internal
{
-Character::Character()
-: mCharacter( 0 )
-{
-}
-
Character::Character( uint32_t character )
: mCharacter( character )
{
}
-Character::Character( const Character& character )
-: mCharacter( character.mCharacter )
-{
-}
-
-Character& Character::operator=( const Character& character )
-{
- mCharacter = character.mCharacter;
-
- return *this;
-}
-
Character::~Character()
{
}
bool Character::IsWhiteSpace() const
{
- // TODO: It should cover unicode characters: http://en.wikipedia.org/wiki/Whitespace_character
- return mCharacter <= CHAR_WHITE_SPACE;
+ return Character::IsWhiteSpace( mCharacter );
}
bool Character::IsNewLine() const
{
- return mCharacter == CHAR_NEW_LINE;
+ return Character::IsNewLine( mCharacter );
}
uint32_t Character::GetCharacter() const
mCharacter = character;
}
+bool Character::IsWhiteSpace( uint32_t character )
+{
+ // TODO: It should cover unicode characters: http://en.wikipedia.org/wiki/Whitespace_character
+ return character <= CHAR_WHITE_SPACE;
+}
+
+bool Character::IsNewLine( uint32_t character )
+{
+ return character == CHAR_NEW_LINE;
+}
+
} // namespace Internal
} // namespace Dali
public:
- /**
- * @copydoc Dali::Character::Character().
- */
- Character();
-
/**
* Constructor.
* Creates a Character with the given UTF-32 encoded character.
*/
Character( uint32_t character );
- /**
- * @copydoc Dali::Character::Character( const Character& character ).
- */
- Character( const Character& character );
-
- /**
- * @copydoc Dali::Character::operator=( const Character& character ).
- */
- Character& operator=( const Character& character );
-
/**
* Non virtual destructor.
*/
*/
void SetCharacter( uint32_t character );
+ /**
+ * Whether the given character is a white space.
+ *
+ * @param[in] character The character.
+ *
+ * @return \e true the given character is a white space.
+ */
+ static bool IsWhiteSpace( uint32_t character );
+
+ /**
+ * Whether the given character is a new line character.
+ *
+ * @param[in] character The character.
+ *
+ * @return \e true the given character is a new line character.
+ */
+ static bool IsNewLine( uint32_t character );
+
private:
- uint32_t mCharacter;
+
+ // Undefined constructor.
+ Character();
+
+ // Undefined copy constructor.
+ Character( const Character& character );
+
+ // Undefined assignment operator
+ Character& operator=( const Character& character );
+
+ private: //data
+
+ uint32_t mCharacter; ///< Stores the unicode of the character.
};
} // namespace Internal
Text::Text( const std::string& text )
: mString()
{
- if( !text.empty() )
- {
- // minimize allocations for ascii strings
- mString.reserve( text.size() );
+ // minimize allocations for ascii strings
+ mString.reserve( text.size() );
- // break string into UTF-8 tokens
- UTF8Tokenize( reinterpret_cast<const unsigned char*>( text.c_str() ), text.size(), mString );
- }
+ // break string into UTF-8 tokens
+ UTF8Tokenize( reinterpret_cast<const unsigned char*>( text.c_str() ), text.size(), mString );
}
Text::Text( const Character& character )
}
}
-void Text::SetText( const Text& text )
-{
- mString = text.mString;
-}
-
Text& Text::operator=( const Text& text )
{
mString = text.mString;
}
Text::~Text()
+{
+ Clear();
+}
+
+void Text::Clear()
{
mString.clear();
}
void Text::Remove( size_t position, size_t numberOfCharacters )
{
- if( numberOfCharacters == 0 )
- {
- DALI_ASSERT_DEBUG( ( numberOfCharacters != 0 ) && ( "Text::Remove: numberOfCharacters is zero." ) );
- return;
- }
DALI_ASSERT_ALWAYS( position < mString.size() && "Text::Remove: Character position is out of bounds" );
DALI_ASSERT_ALWAYS( position + numberOfCharacters <= mString.size() && "Text::Remove: Character position + numberOfCharacters is out of bounds" );
mString.erase( mString.begin() + position, mString.begin() + position + numberOfCharacters );
}
-void Text::SetTextArray( const TextArray& textArray )
+void Text::Find( uint32_t character, std::size_t from, std::size_t to, Vector<std::size_t>& positions ) const
{
- mString = textArray;
+ std::size_t position = from;
+
+ for( TextArray::const_iterator it = mString.begin() + from, endIt = mString.begin() + to + 1u; it != endIt; ++position, ++it )
+ {
+ if( *it == character )
+ {
+ positions.PushBack( position );
+ }
+ }
}
-void Text::GetTextArray( TextArray& textArray ) const
+void Text::FindWhiteSpace( std::size_t from, std::size_t to, Vector<std::size_t>& positions ) const
{
- textArray = mString;
+ std::size_t position = from;
+
+ for( TextArray::const_iterator it = mString.begin() + from, endIt = mString.begin() + to + 1u; it != endIt; ++position, ++it )
+ {
+ if( Character::IsWhiteSpace( *it ) )
+ {
+ positions.PushBack( position );
+ }
+ }
+}
+
+void Text::FindNewLine( std::size_t from, std::size_t to, Vector<std::size_t>& positions ) const
+{
+ std::size_t position = from;
+
+ for( TextArray::const_iterator it = mString.begin() + from, endIt = mString.begin() + to + 1u; it != endIt; ++position, ++it )
+ {
+ if( Character::IsNewLine( *it ) )
+ {
+ positions.PushBack( position );
+ }
+ }
+}
+
+void Text::GetSubText( std::size_t from, std::size_t to, Text* subText ) const
+{
+ if( to < from )
+ {
+ const std::size_t length = mString.size();
+ const std::size_t rfrom = length - ( from + 1u );
+ const std::size_t rto = length - to;
+ subText->mString.insert( subText->mString.end(), mString.rbegin() + rfrom, mString.rbegin() + rto );
+ }
+ else
+ {
+ subText->mString.insert( subText->mString.end(), mString.begin() + from, mString.begin() + to + 1u );
+ }
+}
+
+bool Text::IsWhiteSpace( std::size_t index ) const
+{
+ if( index < mString.size() )
+ {
+ return Character::IsWhiteSpace( *( mString.begin() + index ) );
+ }
+
+ return false;
+}
+
+bool Text::IsNewLine( std::size_t index ) const
+{
+ if( index < mString.size() )
+ {
+ return Character::IsNewLine( *( mString.begin() + index ) );
+ }
+
+ return false;
}
const TextArray& Text::GetTextArray() const
~Text();
/**
- * Converts stored text encoded in UTF-32 to a std::string encoded with UTF-8.
- * @param [out] text The text resultant of the UTF-32 to UTF-8 conversion.
+ * Clears the text.
*/
- void GetText( std::string& text ) const;
+ void Clear();
/**
- * @copydoc Dali::Text::SetText( const Text& text )
+ * Converts stored text encoded in UTF-32 to a std::string encoded with UTF-8.
+ * @param [out] text The text resultant of the UTF-32 to UTF-8 conversion.
*/
- void SetText( const Text& text );
+ void GetText( std::string& text ) const;
/**
* @copydoc Dali::Text::operator[]()
void Remove( size_t position, size_t numberOfCharacters );
/**
- * Sets a UTF-32 endoded string.
- * @param[in] textArray A UTF-32 endoded string.
+ * @copydoc Dali::Text::Find( const Character& character, std::size_t from, std::size_t to, Vector<std::size_t>& positions )
+ */
+ void Find( uint32_t character, std::size_t from, std::size_t to, Vector<std::size_t>& positions ) const;
+
+ /**
+ * @copydoc Dali::Text::Find( SpecialCharacter character, std::size_t from, std::size_t to, Vector<std::size_t>& positions )
+ */
+ void FindWhiteSpace( std::size_t from, std::size_t to, Vector<std::size_t>& positions ) const;
+
+ /**
+ * @copydoc Dali::Text::Find( SpecialCharacter character, std::size_t from, std::size_t to, Vector<std::size_t>& positions )
+ */
+ void FindNewLine( std::size_t from, std::size_t to, Vector<std::size_t>& positions ) const;
+
+ /**
+ * @copydoc Dali::Text::GetSubText()
+ */
+ void GetSubText( std::size_t from, std::size_t to, Text* subText ) const;
+
+ /**
+ * @copydoc Dali::Text::IsWhiteSpace()
*/
- void SetTextArray( const TextArray& textArray );
+ bool IsWhiteSpace( std::size_t index ) const;
/**
- * Retrieves a copy of the UTF-32 endoded string.
- * @param[out] textArray A copy of the UTF-32 endoded string.
+ * @copydoc Dali::Text::IsNewLine()
*/
- void GetTextArray( TextArray& textArray ) const;
+ bool IsNewLine( std::size_t index ) const;
/**
* Retrieves a reference to the UTF-32 encoded string.
private:
- TextArray mString;
+ TextArray mString; ///< Stores an array of unicodes.
};
} // namespace Internal
#include <dali/public-api/text/text.h>
// INTERNAL INCLUDES
+#include <dali/internal/event/text/character-impl.h>
#include <dali/internal/event/text/text-impl.h>
#include <dali/public-api/common/dali-common.h>
}
else
{
- mImpl->SetTextArray( text.mImpl->GetTextArray() );
+ *mImpl = *text.mImpl;
}
}
}
}
else
{
- mImpl->SetTextArray( text.mImpl->GetTextArray() );
+ *mImpl = *text.mImpl;
}
}
else
{
DALI_ASSERT_ALWAYS( NULL != mImpl && "Text::Remove: Text is uninitialized" );
- if( ( 0 == position ) && ( mImpl->GetLength() == numberOfCharacters ) )
+ if( 0u == numberOfCharacters )
+ {
+ // nothing to remove.
+ return;
+ }
+
+ if( ( 0u == position ) && ( mImpl->GetLength() == numberOfCharacters ) )
{
// If all characters are removed, delete the internal implementation.
delete mImpl;
}
}
+void Text::Find( const Character& character, std::size_t from, std::size_t to, Vector<std::size_t>& positions ) const
+{
+ if( NULL == mImpl )
+ {
+ // nothing to find if the text is not initialized.
+ return;
+ }
+
+ mImpl->Find( character.GetImplementation().GetCharacter(), from, to, positions );
+}
+
+void Text::Find( SpecialCharacter character, std::size_t from, std::size_t to, Vector<std::size_t>& positions ) const
+{
+ // @note There is a different method to find a white space because it is a range of values.
+
+ if( NULL == mImpl )
+ {
+ // nothing to find if the text is not initialized.
+ return;
+ }
+
+ switch( character )
+ {
+ case WHITE_SPACE:
+ {
+ mImpl->FindWhiteSpace( from, to, positions );
+ break;
+ }
+ case NEW_LINE:
+ {
+ mImpl->FindNewLine( from, to, positions );
+ break;
+ }
+ }
+}
+
+void Text::GetSubText( std::size_t from, std::size_t to, Text& subText ) const
+{
+ if( NULL == mImpl )
+ {
+ // nothing to do if the text is not initialized.
+ return;
+ }
+
+ const std::size_t length = mImpl->GetLength();
+
+ if( ( from >= length ) || ( to >= length ) )
+ {
+ // out of bounds access.
+ return;
+ }
+
+ // Create an internal implementation if there isn't one.
+ if( NULL == subText.mImpl )
+ {
+ subText.mImpl = new Internal::Text();
+ }
+ else
+ {
+ subText.mImpl->Clear();
+ }
+
+ mImpl->GetSubText( from, to, subText.mImpl );
+}
+
+bool Text::IsWhiteSpace( std::size_t index ) const
+{
+ if( NULL == mImpl )
+ {
+ // not a white space if the text is not initialized.
+ return false;
+ }
+
+ return mImpl->IsWhiteSpace( index );
+}
+
+bool Text::IsNewLine( std::size_t index ) const
+{
+ if( NULL == mImpl )
+ {
+ // not a new line if the text is not initialized.
+ return false;
+ }
+
+ return mImpl->IsNewLine( index );
+}
+
// Note: Theese two methods are needed to retrieve the internal implementation.
// As this class is pimpled but is not inheriting from BaseHandle, a method is needed in the public API.