Added skeleton TextController
[platform/core/uifw/dali-toolkit.git] / base / dali-toolkit / public-api / text / logical-model.cpp
1 /*
2  * Copyright (c) 2015 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 // CLASS HEADER
19 #include <dali-toolkit/public-api/text/logical-model.h>
20
21 // EXTERNAL INCLUDES
22 #include <string.h>
23
24 namespace Dali
25 {
26
27 namespace Toolkit
28 {
29
30 namespace Text
31 {
32
33 struct LogicalModel::Impl
34 {
35   Vector<Character> mText;
36 };
37
38 LogicalModelPtr LogicalModel::New()
39 {
40   return LogicalModelPtr( new LogicalModel() );
41 }
42
43 void LogicalModel::SetText( const Character* text, Length length )
44 {
45   Vector<Character>& modelText = mImpl->mText;
46   modelText.Resize( length );
47   memcpy( &modelText[0], text, length*sizeof(Character) );
48 }
49
50 Length LogicalModel::GetNumberOfCharacters() const
51 {
52   return mImpl->mText.Count();
53 }
54
55 void LogicalModel::GetText( CharacterIndex characterIndex, Character* text, Length numberOfCharacters ) const
56 {
57   Vector<Character>& modelText = mImpl->mText;
58   memcpy( text, &modelText[characterIndex], numberOfCharacters*sizeof(Character) );
59 }
60
61 LogicalModel::~LogicalModel()
62 {
63   delete mImpl;
64 }
65
66 LogicalModel::LogicalModel()
67 : mImpl( NULL )
68 {
69   mImpl = new LogicalModel::Impl();
70 }
71
72 } // namespace Text
73
74 } // namespace Toolkit
75
76 } // namespace Dali