[dali_2.3.21] Merge branch 'devel/master'
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / devel-api / text / spanned.h
1 #ifndef DALI_TOOLKIT_TEXT_SPANNED_H
2 #define DALI_TOOLKIT_TEXT_SPANNED_H
3
4 /*
5  * Copyright (c) 2023 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 <dali-toolkit/devel-api/text/range.h>
24 #include <dali-toolkit/devel-api/text/spans/base-span.h>
25 #include <dali/public-api/common/dali-vector.h>
26 #include <dali/public-api/common/vector-wrapper.h>
27
28 namespace Dali
29 {
30 namespace Toolkit
31 {
32 namespace Text
33 {
34 namespace Internal DALI_INTERNAL
35 {
36 class Spanned;
37 }
38
39 /**
40  * @brief Interface for text that has spans objects attached to ranges of it.
41  * It provides uniform APIs for read-only access to many different kinds of formatted character sequences.
42  *
43  * @note An instance of this class cannot be created.
44  *
45  */
46 class DALI_TOOLKIT_API Spanned : public CharacterSequence
47 {
48 public:
49   /**
50    * @brief Creates an uninitialized Spanned handle.
51    *
52    * Calling member functions with an uninitialized Spanned handle is not allowed.
53    */
54   Spanned();
55
56   /**
57    * @brief Copy constructor.
58    *
59    * @param[in] rhs A reference to the copied handle
60    */
61   Spanned(const Spanned& rhs);
62
63   /**
64    * @brief Move constructor.
65    *
66    * @param[in] rhs A reference to the handle to move
67    */
68   Spanned(Spanned&& rhs);
69
70   /**
71    * @brief Assignment operator.
72    *
73    * @param[in] handle A reference to the copied handle
74    * @return A reference to this
75    */
76   Spanned& operator=(const Spanned& handle);
77
78   /**
79    * @brief Move assignment operator.
80    *
81    * @param[in] rhs A reference to the handle to move
82    * @return A reference to this handle
83    */
84   Spanned& operator=(Spanned&& rhs);
85
86   /**
87    * @brief Non virtual destructor.
88    */
89   ~Spanned();
90
91 protected:
92   /**
93    * @brief Downcasts to a Spanned handle.
94    * If handle is not a Spanned, the returned handle is left uninitialized.
95    *
96    * @param[in] handle Handle to an object
97    * @return Spanned handle or an uninitialized handle
98    */
99   static Spanned DownCast(BaseHandle handle);
100
101 public:
102   /**
103    * @brief Retrieve all spans.
104    *
105    * @return list of spans
106    */
107   std::vector<BaseSpan> GetAllSpans() const;
108
109   /**
110    * @brief Retrieve all spans and ranges. Two lists are mapped by index.
111    *
112    * @param[out] spans container to clone spans
113    * @param[out] ranges container to clone ranges
114    */
115   void RetrieveAllSpansAndRanges(std::vector<BaseSpan>& spans, std::vector<Range>& ranges) const;
116
117 public: // Not intended for application developers
118   /// @cond internal
119   /**
120    * @brief Internal constructor.
121    *
122    * @param[in] spanned Pointer to internal Spanned
123    */
124   explicit DALI_INTERNAL Spanned(Internal::Spanned* spanned);
125   /// @endcond
126 };
127
128 } // namespace Text
129
130 } // namespace Toolkit
131
132 } // namespace Dali
133
134 #endif // DALI_TOOLKIT_TEXT_SPANNED_H