aboutsummaryrefslogtreecommitdiffstats
path: root/searchlib/src/vespa/searchcommon/attribute/collectiontype.cpp
blob: bcf11f26795f7722e64768305009f298918e3da0 (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
25
26
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#include "collectiontype.h"
#include <vespa/vespalib/util/exceptions.h>

namespace search::attribute {

const CollectionType::TypeInfo CollectionType::_typeTable[CollectionType::MAX_TYPE] = {
    { CollectionType::SINGLE, "single" },
    { CollectionType::ARRAY,  "array" },
    { CollectionType::WSET,   "weightedset" }
};

CollectionType::Type
CollectionType::asType(const vespalib::string &t)
{
    for (size_t i(0); i < sizeof(_typeTable)/sizeof(_typeTable[0]); i++) {
        if (t == _typeTable[i]._name) {
            return _typeTable[i]._type;
        }
    }
    throw vespalib::IllegalStateException(t + " not recognized as valid attribute collection type");
    return SINGLE;
}

}