aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/string_utils/scan/scan.h
blob: 5711bafeab7a7cc5593afe189dabf7ca50ddad2d (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 
        }
    }
}