1 #ifndef DALI_TOOLKIT_INTERNAL_TEXT_SPANNABLE_STRING_IMPL_H
2 #define DALI_TOOLKIT_INTERNAL_TEXT_SPANNABLE_STRING_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/spannable-string.h>
26 #include <dali-toolkit/internal/text/spannable/span-ranges-container-impl.h>
27 #include <dali-toolkit/internal/text/spannable/spannable-impl.h>
37 class SpannableString;
39 typedef IntrusivePtr<SpannableString> SpannableStringPtr;
40 typedef const SpannableString* SpannableStringConstPtr;
43 * @copydoc Dali::Toolkit::Text::SpannableString
45 class SpannableString : public Spannable
49 * @brief Creates a new SpannableString.
51 * @return A public handle to the newly allocated SpannableString.
53 static Dali::Toolkit::Text::SpannableString New(const std::string& text);
58 * A reference counted object may only be deleted by calling Unreference()
60 ~SpannableString() override;
64 * @brief Constructs a new SpannableString.
66 SpannableString(const std::string& text);
68 // Removed constructors and assignment operators
70 SpannableString(const SpannableString&) = delete; ///< Deleted copy constructor
71 SpannableString(SpannableString&&) = delete; ///< Deleted move constructor
72 SpannableString& operator=(const SpannableString&) = delete; ///< Deleted copy assignment operator
73 SpannableString& operator=(SpannableString&&) = delete; ///< Deleted move assignment operator
76 //Methods from CharacterSequence
78 * @copydoc Dali::Toolkit::Text::CharacterSequence::GetCharacters()
80 Vector<uint32_t> GetCharacters() const override;
83 * @copydoc Dali::Toolkit::Text::CharacterSequence::GetNumberOfCharacters()
85 uint32_t GetNumberOfCharacters() const override;
88 * @copydoc Dali::Toolkit::Text::CharacterSequence::ToString()
90 std::string ToString() const override;
92 //Methods from Spannable
94 * @copydoc Dali::Toolkit::Text::Spannable::AttachSpan()
96 bool AttachSpan(const Dali::Toolkit::Text::BaseSpan& styleSpan, const Dali::Toolkit::Text::Range& range);
99 * @copydoc Dali::Toolkit::Text::Spannable::DetachSpan()
101 bool DetachSpan(const Dali::Toolkit::Text::BaseSpan& styleSpan);
103 //Methods from Spanned
105 * @copydoc Dali::Toolkit::Text::Spanned::GetAllSpans()
107 std::vector<Dali::Toolkit::Text::BaseSpan> GetAllSpans() const;
110 * @copydoc Dali::Toolkit::Text::Spanned::RetrieveAllSpansAndRanges()
112 void RetrieveAllSpansAndRanges(std::vector<Dali::Toolkit::Text::BaseSpan>& spans, std::vector<Dali::Toolkit::Text::Range>& ranges) const;
116 std::unique_ptr<Impl> mImpl{nullptr};
118 }; // class SpannableString
120 } // namespace Internal
123 * Helper methods for public API.
125 inline Internal::SpannableString& GetImplementation(Dali::Toolkit::Text::SpannableString& spannableString)
127 DALI_ASSERT_ALWAYS(spannableString && "spannableString handle is empty");
129 BaseObject& handle = spannableString.GetBaseObject();
131 return static_cast<Internal::SpannableString&>(handle);
134 inline const Internal::SpannableString& GetImplementation(const Dali::Toolkit::Text::SpannableString& spannableString)
136 DALI_ASSERT_ALWAYS(spannableString && "spannableString handle is empty");
138 const BaseObject& handle = spannableString.GetBaseObject();
140 return static_cast<const Internal::SpannableString&>(handle);
145 } // namespace Toolkit
147 // Allow SpannableString to be treated as a POD type
149 struct TypeTraits<Dali::Toolkit::Text::Internal::SpannableString> : public Dali::BasicTypes<Dali::Toolkit::Text::Internal::SpannableString>
153 IS_TRIVIAL_TYPE = true
159 #endif // DALI_TOOLKIT_INTERNAL_TEXT_SPANNABLE_STRING_IMPL_H