aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/string_utils/scan/scan.h
blob: 466ea4653764432f5409a4a1720dcbc57bc2402a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#pragma once 
 
#include <util/generic/strbuf.h> 
 
template <bool addAll, char sep, char sepKeyVal, class F>
static inline void ScanKeyValue(TStringBuf s, F&& f) { 
    TStringBuf key, val;
 
    while (!s.empty()) {
        val = s.NextTok(sep);
 
        if (val.empty()) {
            continue; // && case
        } 
 
        key = val.NextTok(sepKeyVal);
 
        if (addAll || val.IsInited()) { 
            f(key, val); // includes empty keys
        } 
    } 
}