aboutsummaryrefslogtreecommitdiffstats
path: root/document/src/vespa/document/fieldset/fieldsetrepo.h
blob: 633e0e8cb70e94735a82a793d4567924fc17c336 (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 Vespa.ai. 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;
};

}