2 * Copyright (c) 2022 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 #include <dali-toolkit/internal/text/string-text/range-impl.h>
31 u_int32_t mStartIndex; /// The start index of range
32 u_int32_t mEndIndex; /// The end index of range
35 Dali::Toolkit::Text::Range Range::New(u_int32_t startIndex, u_int32_t endIndex)
37 RangePtr object = new Range(startIndex, endIndex);
39 Dali::Toolkit::Text::Range handle = Dali::Toolkit::Text::Range(object.Get());
44 Range::Range(u_int32_t startIndex, u_int32_t endIndex)
46 mImpl = std::make_unique<Impl>();
48 mImpl->mStartIndex = startIndex <= endIndex ? startIndex : endIndex;
49 mImpl->mEndIndex = startIndex >= endIndex ? startIndex : endIndex;
56 u_int32_t Range::GetStartIndex() const
58 return mImpl->mStartIndex;
61 u_int32_t Range::GetEndIndex() const
63 return mImpl->mEndIndex;
66 u_int32_t Range::GetNumberOfIndices() const
68 return 1u + ((mImpl->mStartIndex <= mImpl->mEndIndex) ? (mImpl->mEndIndex - mImpl->mStartIndex) : (mImpl->mStartIndex - mImpl->mEndIndex));
71 } // namespace Internal
75 } // namespace Toolkit