aboutsummaryrefslogtreecommitdiffstats
path: root/searchcore/src/vespa/searchcore/proton/common/select_utils.cpp
blob: 8fe6579e31ac9740335e54f0d41f813752cf189a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#include "select_utils.h"
#include <vespa/document/select/valuenodes.h>

namespace proton {

vespalib::string
SelectUtils::extractFieldName(const document::select::FieldValueNode &expr, bool &isComplex)
{
    vespalib::string result = expr.getFieldName();
    isComplex = false;
    for (uint32_t i = 0; i < result.size(); ++i) {
        if (result[i] == '.' || result[i] == '{' || result[i] == '[') {
            // TODO: Check for struct, array, map or weigthed set
            result = expr.getFieldName().substr(0, i);
            isComplex = true;
            break;
        }
    }
    return result;
}

}