aboutsummaryrefslogtreecommitdiff
path: root/src/descriptor_set_and_binding_parser.h
blob: 145aa423a7f63669720d24bb4ae60b19d5ea41e6 (plain)
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// Copyright 2019 The Amber Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#ifndef SRC_DESCRIPTOR_SET_AND_BINDING_PARSER_H_
#define SRC_DESCRIPTOR_SET_AND_BINDING_PARSER_H_

#include <string>

#include "amber/result.h"

namespace amber {

/// Class for descriptor set and binding parser.
class DescriptorSetAndBindingParser {
 public:
  DescriptorSetAndBindingParser();
  ~DescriptorSetAndBindingParser();

  /// Run the parser against |buffer_id|. The result is success if the parse
  /// completes correctly. |buffer_id| must be non-empty string. It must
  /// be a single non-negative integer or two those integers separated by
  /// ':'. For example, ":0", "1", and "2:3" are valid strings for |buffer_id|,
  /// but "", "-4", ":-5", ":", "a", and "b:c" are invalid strings for
  /// |buffer_id|. The |buffer_id| can be prefixed by the name of a pipeline.
  Result Parse(const std::string& buffer_id);

  /// Returns true if a pipeline name was specified
  bool HasPipelineName() const { return !pipeline_name_.empty(); }
  std::string PipelineName() const { return pipeline_name_; }

  /// Return descriptor set that is the result of Parse().
  uint32_t GetDescriptorSet() const { return descriptor_set_; }

  /// Return binding that is the result of Parse().
  uint32_t GetBinding() const { return binding_; }

 private:
  std::string pipeline_name_;
  uint32_t descriptor_set_ = 0;
  uint32_t binding_ = 0;
};

}  // namespace amber

#endif  // SRC_DESCRIPTOR_SET_AND_BINDING_PARSER_H_