ATLAS Offline Software
Loading...
Searching...
No Matches
StringColumn.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
6
7
8#ifndef COLUMNAR_CORE_STRING_COLUMN_H
9#define COLUMNAR_CORE_STRING_COLUMN_H
10
12
13namespace columnar
14{
15 namespace detail
16 {
17 // in xAOD mode we can do a straightforward conversion from
18 // std::string to std::string_view, as xAODs natively use std::string
19 template<>
21 {
24 public:
25
27 static constexpr bool isDefined = true;
28 static constexpr bool viewIsReference = false;
29 static constexpr bool hasSetter = false;
30 using MemoryType = std::string;
31
32 static void updateColumnInfo (ColumnInfo& /*info*/) {}
33
34 [[nodiscard]] static auto makeViewer (void**)
35 {
36 return [] (const std::string& value) {return std::string_view (value);};
37 }
38 };
39
40
41
42 // in Array mode we can do a straightforward conversion from
43 // std::vector<char> to std::string_view, as uproot natively
44 // represents it as a vector of char
45 template<>
47 {
50 public:
51
55
56 static constexpr bool isDefined = true;
57 static constexpr unsigned internalOffsetColumns = BaseAccessor::internalOffsetColumns;
58
60
61 ContainerFreeAccessor (ColumnarTool<CM>& columnarTool, ColumnAccessorOptions&& options, ColumnAccessorOptionsArray&& optionsArray)
62 : m_accessor (columnarTool, std::move (options), std::move (optionsArray))
63 {}
64
65 auto operator () (void** dataArea, std::size_t index) const noexcept
66 {
67 std::span<const char> base = m_accessor(dataArea, index);
68 return std::string_view (base.data(), base.size());
69 }
70
71 auto operator () (void** dataArea, std::size_t beginIndex, std::size_t endIndex) const noexcept
72 {
73 return detail::VectorConvertView ([] (std::span<const char> base) noexcept {
74 return std::string_view (base.data(), base.size());},
75 m_accessor(dataArea, beginIndex, endIndex));
76 }
77
78 bool isAvailable (void** dataArea) const noexcept
79 {
80 return m_accessor.isAvailable (dataArea);
81 }
82
85 private:
86
88 };
89 }
90}
91
92#endif
the base class for all columnar components
ContainerFreeAccessor(ColumnarTool< CM > &columnarTool, ColumnAccessorOptions &&options, ColumnAccessorOptionsArray &&optionsArray)
a help implementation of AccessorTemplate that handles type conversions
STL class.
std::string base
Definition hcg.cxx:81
VectorConvertView(FunctionType &&, ViewType &&) -> VectorConvertView< std::decay_t< FunctionType >, std::decay_t< ViewType > >
ColumnAccessMode
an enum for the different access modes for a column
Definition ColumnInfo.h:19
@ input
an input column
Definition ColumnInfo.h:21
Definition index.py:1
STL namespace.
a struct that contains meta-information about each column that's needed to interface the column with ...
Definition ColumnInfo.h:35