[dali_2.3.24] Merge branch 'devel/master'
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / text / spannable / spanned-impl.h
1 #ifndef DALI_TOOLKIT_INTERNAL_TEXT_SPANNED_IMPL_H
2 #define DALI_TOOLKIT_INTERNAL_TEXT_SPANNED_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/spanned.h>
23
24 // INTERNAL INCLUDES
25 #include <dali-toolkit/internal/text/string-text/character-sequence-impl.h>
26
27 namespace Dali
28 {
29 namespace Toolkit
30 {
31 namespace Text
32 {
33 namespace Internal
34 {
35 class CharacterSequence;
36 class Spanned;
37
38 typedef IntrusivePtr<Spanned> SpannedPtr;
39 typedef const Spanned*        SpannedConstPtr;
40
41 /**
42  * @copydoc Dali::Toolkit::Text::Spanned
43  */
44 class Spanned : public CharacterSequence
45 {
46 public:
47   /**
48    * This constructor is only used by derived classes.
49    */
50   Spanned();
51
52   /**
53    * @brief Virtual destructor.
54    *
55    * A reference counted object may only be deleted by calling Unreference()
56    */
57   virtual ~Spanned() = 0;
58
59   // Removed constructors and assignment operators
60 public:                                        // Constructors
61   Spanned(const Spanned&) = delete;            ///< Deleted copy constructor
62   Spanned(Spanned&&)      = delete;            ///< Deleted move constructor
63   Spanned& operator=(const Spanned&) = delete; ///< Deleted copy assignment operator
64   Spanned& operator=(Spanned&&) = delete;      ///< Deleted move assignment operator
65
66 public: //Methods
67   /**
68    * @copydoc Dali::Toolkit::Text::Spanned::GetAllSpans()
69    */
70   virtual std::vector<Dali::Toolkit::Text::BaseSpan> GetAllSpans() const = 0;
71
72   /**
73    * @copydoc Dali::Toolkit::Text::Spanned::RetrieveAllSpansAndRanges()
74    */
75   virtual void RetrieveAllSpansAndRanges(std::vector<Dali::Toolkit::Text::BaseSpan>& spans, std::vector<Dali::Toolkit::Text::Range>& ranges) const = 0;
76
77 }; // class Spanned
78
79 } // namespace Internal
80
81 /**
82  * Helper methods for public API.
83  */
84 inline Internal::Spanned& GetImplementation(Dali::Toolkit::Text::Spanned& spanned)
85 {
86   DALI_ASSERT_ALWAYS(spanned && "spanned handle is empty");
87
88   BaseObject& handle = spanned.GetBaseObject();
89
90   return static_cast<Internal::Spanned&>(handle);
91 }
92
93 inline const Internal::Spanned& GetImplementation(const Dali::Toolkit::Text::Spanned& spanned)
94 {
95   DALI_ASSERT_ALWAYS(spanned && "spanned handle is empty");
96
97   const BaseObject& handle = spanned.GetBaseObject();
98
99   return static_cast<const Internal::Spanned&>(handle);
100 }
101
102 } // namespace Text
103
104 } // namespace Toolkit
105
106 // Allow Spanned to be treated as a POD type
107 template<>
108 struct TypeTraits<Dali::Toolkit::Text::Internal::Spanned> : public Dali::BasicTypes<Dali::Toolkit::Text::Internal::Spanned>
109 {
110   enum
111   {
112     IS_TRIVIAL_TYPE = true
113   };
114 };
115
116 } // namespace Dali
117
118 #endif // DALI_TOOLKIT_INTERNAL_TEXT_SPANNED_IMPL_H