9 #ifndef ICARUSCODE_DECODE_DECODERTOOLS_DETAILS_KEYEDCVSPARSER_H
10 #define ICARUSCODE_DECODE_DECODERTOOLS_DETAILS_KEYEDCVSPARSER_H
17 #include <string_view>
22 #include <initializer_list>
26 #include <type_traits>
32 namespace icarus::details {
class KeyedCSVparser; }
85 = std::numeric_limits<unsigned int>::max();
97 template <
typename BIter,
typename EIter>
102 template <
typename BIter,
typename EIter>
142 {
fPatterns.emplace_back(std::move(pattern), values);
return *
this; }
156 (std::initializer_list<std::pair<std::regex, unsigned int>> patterns);
158 (std::initializer_list<std::pair<std::string, unsigned int>> patterns);
170 std::vector<std::pair<std::regex, unsigned int>>
fPatterns;
185 template <
typename String>
195 template <
char... Chars>
225 "data ended while expecting " +
std::
to_string(values) +
" more values"
243 template <
typename BIter,
typename EIter>
252 #endif // ICARUSCODE_DECODE_DECODERTOOLS_DETAILS_KEYEDCVSPARSER_H
static constexpr unsigned int FixedSize
Expected values are missing.
Parser to fill a KeyValuesData structure out of a character buffer.
KeyedCSVparser(char sep= ',')
Constructor: specifies the separator character.
double std(const std::vector< short > &wf, const double ped_mean, size_t start, size_t nsample)
ParserError(std::string msg)
bool isKey(SubBuffer_t const &buffer) const noexcept
Is content of buffer a key (as opposed to a value)?
static SubBuffer_t stripRightChars(SubBuffer_t s) noexcept
ParsedData_t operator()(std::string_view const &s) const
std::size_t size(FixedBins< T, C > const &) noexcept
static SubBuffer_t stripRight(SubBuffer_t s) noexcept
char const fSep
Character used as token separator.
KeyedCSVparser & addPattern(std::regex pattern, unsigned int values)
Adds a single known pattern.
Simple parsed data format.
ParsedData_t parse(std::string_view const &s) const
Parses the buffer s and returns a data structure with the content.
static SubBuffer_t stripRightChar(SubBuffer_t s, char c) noexcept
double distance(geo::Point_t const &point, CathodeDesc_t const &cathode)
Returns the distance of a point from the cathode.
static Buffer_t & moveBufferHead(Buffer_t &buffer, std::size_t size) noexcept
static constexpr unsigned int DynamicSize
Mnemonic size value used in addPattern() calls.
Collection of items with key/values structure.
std::size_t findTokenLength(Buffer_t const &buffer) const noexcept
Returns the length of the next toke, up to the next separator (excluded).
KeyedCSVparser & addPatterns(std::initializer_list< std::pair< std::regex, unsigned int >> patterns)
Adds known patterns.
std::vector< std::pair< std::regex, unsigned int > > fPatterns
List of known patterns for matching keys, and how many values they hold.
static SubBuffer_t stripLeft(SubBuffer_t s) noexcept
SubBuffer_t extractToken(Buffer_t &buffer) const noexcept
Extracts the next token from the buffer and returns its value, stripped.
std::string to_string(WindowPattern const &pattern)
then echo File list $list not found else cat $list while read file do echo $file sed s
static SubBuffer_t strip(SubBuffer_t s) noexcept
KeyedCSVparser & addPattern(std::string const &pattern, unsigned int values)
icarus::KeyValuesData ParsedData_t
std::string_view Buffer_t
SubBuffer_t peekToken(Buffer_t const &buffer) const noexcept
Returns the value of the next token, stripped.
MissingValues(std::string const &key, unsigned int values)
std::string_view SubBuffer_t
static Buffer_t makeBuffer(String const &s) noexcept