1 #ifndef DALI_TOOLKIT_INTERNAL_TEXT_SPANS_CONTAINER_IMPL_H
2 #define DALI_TOOLKIT_INTERNAL_TEXT_SPANS_CONTAINER_IMPL_H
5 * Copyright (c) 2022 Samsung Electronics Co., Ltd.
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
22 #include <dali-toolkit/devel-api/text/range.h>
23 #include <dali-toolkit/devel-api/text/spans/base-span.h>
24 #include <dali/public-api/common/dali-vector.h>
25 #include <dali/public-api/math/vector4.h>
29 #include <dali-toolkit/internal/text/spannable/spans/base-span-impl.h>
30 #include <dali-toolkit/internal/text/string-text/range-impl.h>
40 class SpanRangesContainer;
43 * @brief The container for style spans.
44 * This is to isolate the responsibility of container type from the logic of the spanned text.
46 class SpanRangesContainer
50 * @brief Default constructor.
52 SpanRangesContainer();
55 * @brief Virtual destructor.
57 * A reference counted object may only be deleted by calling Unreference()
59 ~SpanRangesContainer();
64 * @brief Add the span to the list of spans.
66 * @param[in] span The span of style.
67 * @param[in] range The range.
70 void AddSpan(const Dali::Toolkit::Text::BaseSpan& span, const Dali::Toolkit::Text::Range& range);
73 * @brief Remove the span from the list.
75 * @param[in] span The span of style.
78 void RemoveSpan(const Dali::Toolkit::Text::BaseSpan& span);
81 * @brief Check if a given @p span is in list
83 * @param[in] span The span of style.
85 * @return true if the @p span exists. Otherwise false.
87 bool Contains(const Dali::Toolkit::Text::BaseSpan& span) const;
90 * @brief Retrieve all spans.
92 * @param[out] listOfSpans container to clone spans
94 void GetSpans(std::vector<Dali::Toolkit::Text::BaseSpan>& listOfSpans) const;
97 * @brief Retrieve all spans and ranges.
99 * @param[out] spans container to clone spans
100 * @param[out] ranges container to clone ranges
102 void GetSpansAndRanges(std::vector<Dali::Toolkit::Text::BaseSpan>& spans, std::vector<Dali::Toolkit::Text::Range>& ranges) const;
104 // Removed constructors and assignment operators
105 public: // Constructors
106 SpanRangesContainer(const SpanRangesContainer&) = delete; ///< Deleted copy constructor
107 SpanRangesContainer(SpanRangesContainer&&) = delete; ///< Deleted move constructor
108 SpanRangesContainer& operator=(const SpanRangesContainer&) = delete; ///< Deleted copy assignment operator
109 SpanRangesContainer& operator=(SpanRangesContainer&&) = delete; ///< Deleted move assignment operator
114 std::unique_ptr<Impl> mImpl{nullptr};
116 }; // class SpanRangesContainer
118 } // namespace Internal
122 } // namespace Toolkit
124 // Allow SpanRangesContainer to be treated as a POD type
126 struct TypeTraits<Dali::Toolkit::Text::Internal::SpanRangesContainer> : public Dali::BasicTypes<Dali::Toolkit::Text::Internal::SpanRangesContainer>
130 IS_TRIVIAL_TYPE = true
136 #endif // DALI_TOOLKIT_INTERNAL_TEXT_SPANS_CONTAINER_IMPL_H