1 // Copyright 2019 The Amber Authors. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 #ifndef SRC_DESCRIPTOR_SET_AND_BINDING_PARSER_H_ 16 #define SRC_DESCRIPTOR_SET_AND_BINDING_PARSER_H_ 17 18 #include <cstdint> 19 #include <string> 20 21 #include "amber/result.h" 22 23 namespace amber { 24 25 /// Class for descriptor set and binding parser. 26 class DescriptorSetAndBindingParser { 27 public: 28 DescriptorSetAndBindingParser(); 29 ~DescriptorSetAndBindingParser(); 30 31 /// Run the parser against |buffer_id|. The result is success if the parse 32 /// completes correctly. |buffer_id| must be non-empty string. It must 33 /// be a single non-negative integer or two those integers separated by 34 /// ':'. For example, ":0", "1", and "2:3" are valid strings for |buffer_id|, 35 /// but "", "-4", ":-5", ":", "a", and "b:c" are invalid strings for 36 /// |buffer_id|. The |buffer_id| can be prefixed by the name of a pipeline. 37 Result Parse(const std::string& buffer_id); 38 39 /// Returns true if a pipeline name was specified HasPipelineName()40 bool HasPipelineName() const { return !pipeline_name_.empty(); } PipelineName()41 std::string PipelineName() const { return pipeline_name_; } 42 43 /// Return descriptor set that is the result of Parse(). GetDescriptorSet()44 uint32_t GetDescriptorSet() const { return descriptor_set_; } 45 46 /// Return binding that is the result of Parse(). GetBinding()47 uint32_t GetBinding() const { return binding_; } 48 49 private: 50 std::string pipeline_name_; 51 uint32_t descriptor_set_ = 0; 52 uint32_t binding_ = 0; 53 }; 54 55 } // namespace amber 56 57 #endif // SRC_DESCRIPTOR_SET_AND_BINDING_PARSER_H_ 58