aboutsummaryrefslogtreecommitdiffstats
path: root/document/src/vespa/document/fieldset/fieldsetrepo.h
blob: 6b641b963af8af255357cdad7081d14e09cf00f9 (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
27
28
29
30
31
32
33
34
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once

#include <vespa/document/fieldset/fieldset.h>
#include <vespa/document/fieldset/fieldsets.h>
#include <vespa/document/datatype/documenttype.h>

namespace document {

class DocumentTypeRepo;

/**
 * Class that has configuration for all document field sets.
 * Responsible for parsing field set strings using a documenttype.
 */
class FieldSetRepo
{
public:
    FieldSetRepo(const DocumentTypeRepo& repo);
    ~FieldSetRepo();

    FieldSet::SP getFieldSet(vespalib::stringref fieldSetString) const;

    static FieldSet::SP parse(const DocumentTypeRepo& repo, vespalib::stringref fieldSetString);
    static vespalib::string serialize(const FieldSet& fs);
private:
    void configureDocumentType(const DocumentType & documentType);
    const DocumentTypeRepo & _doumentTyperepo;
    vespalib::hash_map<vespalib::string, FieldSet::SP> _configuredFieldSets;
};

}