[dali_2.3.21] Merge branch 'devel/master'
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / text / string-text / character-sequence-impl.h
1 #ifndef DALI_TOOLKIT_INTERNAL_TEXT_CHARACTER_SEQUENCE_IMPL_H
2 #define DALI_TOOLKIT_INTERNAL_TEXT_CHARACTER_SEQUENCE_IMPL_H
3
4 /*
5  * Copyright (c) 2022 Samsung Electronics Co., Ltd.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  */
20
21 // EXTERNAL INCLUDES
22 #include <dali-toolkit/devel-api/text/character-sequence.h>
23 #include <memory>
24
25 // INTERNAL INCLUDES
26 #include <dali-toolkit/internal/text/text-definitions.h>
27 #include <dali/public-api/object/base-object.h>
28
29 namespace Dali
30 {
31 namespace Toolkit
32 {
33 namespace Text
34 {
35 namespace Internal
36 {
37 class CharacterSequence;
38
39 typedef IntrusivePtr<CharacterSequence> CharacterSequencePtr;
40 typedef const CharacterSequence*        CharacterSequenceConstPtr;
41
42 /**
43  * @copydoc Dali::Toolkit::Text::CharacterSequence
44  */
45 class CharacterSequence : public BaseObject
46 {
47 public:
48   /**
49    * This constructor is only used by derived classes.
50    */
51   CharacterSequence();
52
53   /**
54    * @brief Virtual destructor.
55    *
56    * A reference counted object may only be deleted by calling Unreference()
57    */
58   virtual ~CharacterSequence() = 0;
59
60   // Removed constructors and assignment operators
61 public:
62   CharacterSequence(const CharacterSequence&) = delete;            ///< Deleted copy constructor
63   CharacterSequence(CharacterSequence&&)      = delete;            ///< Deleted move constructor
64   CharacterSequence& operator=(const CharacterSequence&) = delete; ///< Deleted copy assignment operator
65   CharacterSequence& operator=(CharacterSequence&&) = delete;      ///< Deleted move assignment operator
66
67 public: //Methods
68   /**
69    * @copydoc Dali::Toolkit::Text::CharacterSequence::GetCharacters()
70    */
71   virtual Vector<uint32_t> GetCharacters() const = 0;
72
73   /**
74    * @copydoc Dali::Toolkit::Text::CharacterSequence::GetNumberOfCharacters()
75    */
76   virtual uint32_t GetNumberOfCharacters() const = 0;
77
78   /**
79    * @copydoc Dali::Toolkit::Text::CharacterSequence::ToString()
80    */
81   virtual std::string ToString() const = 0;
82
83 }; // class CharacterSequence
84
85 } // namespace Internal
86
87 /**
88  * Helper methods for public API.
89  */
90 inline Internal::CharacterSequence& GetImplementation(Dali::Toolkit::Text::CharacterSequence& characterSequence)
91 {
92   DALI_ASSERT_ALWAYS(characterSequence && "characterSequence handle is empty");
93
94   BaseObject& handle = characterSequence.GetBaseObject();
95
96   return static_cast<Internal::CharacterSequence&>(handle);
97 }
98
99 inline const Internal::CharacterSequence& GetImplementation(const Dali::Toolkit::Text::CharacterSequence& characterSequence)
100 {
101   DALI_ASSERT_ALWAYS(characterSequence && "characterSequence handle is empty");
102
103   const BaseObject& handle = characterSequence.GetBaseObject();
104
105   return static_cast<const Internal::CharacterSequence&>(handle);
106 }
107
108 } // namespace Text
109
110 } // namespace Toolkit
111
112 // Allow AbstractStyleSpan to be treated as a POD type
113 template<>
114 struct TypeTraits<Dali::Toolkit::Text::Internal::CharacterSequence> : public Dali::BasicTypes<Dali::Toolkit::Text::Internal::CharacterSequence>
115 {
116   enum
117   {
118     IS_TRIVIAL_TYPE = true
119   };
120 };
121
122 } // namespace Dali
123
124 #endif // DALI_TOOLKIT_INTERNAL_TEXT_CHARACTER_SEQUENCE_IMPL_H