impl Namespace Reference

impl Namespace Reference#

Rocprofiler SDK Developer API: rocprofiler::sdk::join::impl Namespace Reference
Rocprofiler SDK Developer API 0.5.0
ROCm Profiling API and tools
rocprofiler::sdk::join::impl Namespace Reference

Functions

template<int TraitT, typename ArgT >
decltype(auto) join_arg (config _cfg, ArgT &&_v)
 

Function Documentation

◆ join_arg()

template<int TraitT, typename ArgT >
decltype(auto) rocprofiler::sdk::join::impl::join_arg ( config  _cfg,
ArgT &&  _v 
)
inline

Definition at line 126 of file join.hpp.

127{
128 using arg_type = mpl::basic_identity_t<ArgT>;
129
130 constexpr bool _is_string_type = mpl::is_string_type<arg_type>::value;
131 constexpr bool _is_iterable = mpl::is_iterable<arg_type>(0);
132 constexpr bool _has_traits_type = mpl::has_traits<arg_type>(0);
133 constexpr bool _has_key_type = mpl::has_key_type<arg_type>(0);
134 constexpr bool _has_value_type = mpl::has_value_type<arg_type>(0);
135 constexpr bool _has_mapped_type = mpl::has_mapped_type<arg_type>(0);
136
137 if constexpr(_is_string_type)
138 {
139 if constexpr(TraitT == QuoteStrings)
140 {
141 return std::string{"\""} + std::string{std::forward<ArgT>(_v)} + std::string{"\""};
142 }
143 else
144 {
145 return std::forward<ArgT>(_v);
146 }
147 }
148 else if constexpr(_is_iterable && !_has_traits_type &&
149 (_has_value_type || (_has_key_type && _has_mapped_type)))
150 {
151 if constexpr(_has_key_type && _has_mapped_type)
152 {
153 std::stringstream _ss{};
154 _ss.setf(_cfg.flags);
155 for(auto&& itr : std::forward<ArgT>(_v))
156 _ss << _cfg.array.delimiter << _cfg.pair.prefix << join_arg<TraitT>(_cfg, itr.first)
157 << _cfg.pair.delimiter << join_arg<TraitT>(_cfg, itr.second)
158 << _cfg.pair.suffix;
159 auto _ret = _ss.str();
160 auto&& _len = _cfg.array.delimiter.length();
161 return (_ret.length() > _len) ? (std::string{_cfg.array.prefix} + _ret.substr(_len) +
162 std::string{_cfg.array.suffix})
163 : std::string{};
164 }
165 else if constexpr(_has_value_type)
166 {
167 std::stringstream _ss{};
168 _ss.setf(_cfg.flags);
169 for(auto&& itr : std::forward<ArgT>(_v))
170 _ss << _cfg.array.delimiter << join_arg<TraitT>(_cfg, itr);
171 auto _ret = _ss.str();
172 auto&& _len = _cfg.array.delimiter.length();
173 return (_ret.length() > _len) ? (std::string{_cfg.array.prefix} + _ret.substr(_len) +
174 std::string{_cfg.array.suffix})
175 : std::string{};
176 }
177 }
178 else if constexpr(mpl::supports_ostream<ArgT>(0))
179 {
180 return std::forward<ArgT>(_v);
181 }
182 else
183 {
184 static_assert(_is_iterable, "Type is not iterable");
185 static_assert(!_has_traits_type, "Type has a traits type");
186 if constexpr(!_has_value_type)
187 {
188 static_assert(_has_key_type && _has_mapped_type,
189 "Type must have a key_type and mapped_type if there is no value_type");
190 }
191 else
192 {
193 static_assert(_has_value_type,
194 "Type must have a value_type if there is no key_type and mapped_type");
195 }
196 static_assert(std::is_empty<ArgT>::value,
197 "Error! argument type cannot be written to output stream");
198 }
199 // suppress any unused but set variable warnings
200 consume_args(_is_string_type,
201 _is_iterable,
202 _has_traits_type,
203 _has_key_type,
204 _has_value_type,
205 _has_mapped_type);
206}
decltype(auto) join_arg(config _cfg, ArgT &&_v)
Definition join.hpp:126
void consume_args(ArgsT &&...)
Definition join.hpp:45
STL namespace.

References rocprofiler::sdk::join::config::array, rocprofiler::sdk::join::consume_args(), rocprofiler::sdk::join::triplet_config< Idx >::delimiter, rocprofiler::sdk::join::config::flags, rocprofiler::sdk::join::config::pair, rocprofiler::sdk::join::triplet_config< Idx >::prefix, rocprofiler::sdk::join::QuoteStrings, and rocprofiler::sdk::join::triplet_config< Idx >::suffix.

+ Here is the call graph for this function: