X-Git-Url: https://git.mdrn.pl/wl-app.git/blobdiff_plain/53b27422d140022594fc241cca91c3183be57bca..48b2fe9f7c2dc3d9aeaaa6dbfb27c7da4f3235ff:/iOS/Pods/Realm/include/core/realm/column_tpl.hpp diff --git a/iOS/Pods/Realm/include/core/realm/column_tpl.hpp b/iOS/Pods/Realm/include/core/realm/column_tpl.hpp new file mode 100644 index 0000000..2411007 --- /dev/null +++ b/iOS/Pods/Realm/include/core/realm/column_tpl.hpp @@ -0,0 +1,143 @@ +/************************************************************************* + * + * Copyright 2016 Realm Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + **************************************************************************/ + +#ifndef REALM_COLUMN_TPL_HPP +#define REALM_COLUMN_TPL_HPP + +#include + +#include +#include +#include + +namespace realm { + +template +class FloatDoubleNode; +template +class IntegerNode; +template +class SequentialGetter; + +template +struct ColumnTypeTraits2; + +template +struct ColumnTypeTraits2 { + typedef IntegerColumn column_type; + typedef ArrayInteger array_type; +}; +template +struct ColumnTypeTraits2 { + typedef IntegerColumn column_type; + typedef ArrayInteger array_type; +}; +template +struct ColumnTypeTraits2 { + typedef FloatColumn column_type; + typedef ArrayFloat array_type; +}; +template +struct ColumnTypeTraits2 { + typedef DoubleColumn column_type; + typedef ArrayDouble array_type; +}; + + +namespace _impl { + +template +struct FindInLeaf { + using LeafType = typename ColType::LeafType; + + template + static bool find(const LeafType& leaf, T target, size_t local_start, size_t local_end, size_t leaf_start, + QueryState& state) + { + Condition cond; + bool cont = true; + // todo, make an additional loop with hard coded `false` instead of is_null(v) for non-nullable columns + bool null_target = null::is_null_float(target); + for (size_t local_index = local_start; cont && local_index < local_end; local_index++) { + auto v = leaf.get(local_index); + if (cond(v, target, null::is_null_float(v), null_target)) { + cont = state.template match(leaf_start + local_index, 0, static_cast(v)); + } + } + return cont; + } +}; + +template <> +struct FindInLeaf { + using LeafType = IntegerColumn::LeafType; + + template + static bool find(const LeafType& leaf, T target, size_t local_start, size_t local_end, size_t leaf_start, + QueryState& state) + { + const int c = Condition::condition; + return leaf.find(c, action, target, local_start, local_end, leaf_start, &state); + } +}; + +template <> +struct FindInLeaf { + using LeafType = IntNullColumn::LeafType; + + template + static bool find(const LeafType& leaf, T target, size_t local_start, size_t local_end, size_t leaf_start, + QueryState& state) + { + constexpr int cond = Condition::condition; + return leaf.find(cond, action, target, local_start, local_end, leaf_start, &state); + } +}; + +} // namespace _impl + +template +R aggregate(const ColType& column, T target, size_t start, size_t end, size_t limit, size_t* return_ndx) +{ + if (end == npos) + end = column.size(); + + QueryState state; + state.init(action, nullptr, limit); + SequentialGetter sg{&column}; + + bool cont = true; + for (size_t s = start; cont && s < end;) { + sg.cache_next(s); + size_t start2 = s - sg.m_leaf_start; + size_t end2 = sg.local_end(end); + cont = _impl::FindInLeaf::template find(*sg.m_leaf_ptr, target, start2, end2, + sg.m_leaf_start, state); + s = sg.m_leaf_start + end2; + } + + if (return_ndx) + *return_ndx = action == act_Sum ? state.m_match_count : state.m_minmax_index; + + return state.m_state; +} + + +} // namespace realm + +#endif // REALM_COLUMN_TPL_HPP