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