| // Copyright 2022 The Tint 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. |
| |
| //////////////////////////////////////////////////////////////////////////////// |
| // File generated by tools/src/cmd/gen |
| // using the template: |
| // src/tint/type/short_name.cc.tmpl |
| // |
| // Do not modify this file directly |
| //////////////////////////////////////////////////////////////////////////////// |
| |
| #include "src/tint/type/short_name.h" |
| |
| namespace tint::type { |
| |
| /// ParseShortName parses a ShortName from a string. |
| /// @param str the string to parse |
| /// @returns the parsed enum, or ShortName::kUndefined if the string could not be parsed. |
| ShortName ParseShortName(std::string_view str) { |
| if (str == "vec2f") { |
| return ShortName::kVec2F; |
| } |
| if (str == "vec2h") { |
| return ShortName::kVec2H; |
| } |
| if (str == "vec2i") { |
| return ShortName::kVec2I; |
| } |
| if (str == "vec2u") { |
| return ShortName::kVec2U; |
| } |
| if (str == "vec3f") { |
| return ShortName::kVec3F; |
| } |
| if (str == "vec3h") { |
| return ShortName::kVec3H; |
| } |
| if (str == "vec3i") { |
| return ShortName::kVec3I; |
| } |
| if (str == "vec3u") { |
| return ShortName::kVec3U; |
| } |
| if (str == "vec4f") { |
| return ShortName::kVec4F; |
| } |
| if (str == "vec4h") { |
| return ShortName::kVec4H; |
| } |
| if (str == "vec4i") { |
| return ShortName::kVec4I; |
| } |
| if (str == "vec4u") { |
| return ShortName::kVec4U; |
| } |
| return ShortName::kUndefined; |
| } |
| |
| std::ostream& operator<<(std::ostream& out, ShortName value) { |
| switch (value) { |
| case ShortName::kUndefined: |
| return out << "undefined"; |
| case ShortName::kVec2F: |
| return out << "vec2f"; |
| case ShortName::kVec2H: |
| return out << "vec2h"; |
| case ShortName::kVec2I: |
| return out << "vec2i"; |
| case ShortName::kVec2U: |
| return out << "vec2u"; |
| case ShortName::kVec3F: |
| return out << "vec3f"; |
| case ShortName::kVec3H: |
| return out << "vec3h"; |
| case ShortName::kVec3I: |
| return out << "vec3i"; |
| case ShortName::kVec3U: |
| return out << "vec3u"; |
| case ShortName::kVec4F: |
| return out << "vec4f"; |
| case ShortName::kVec4H: |
| return out << "vec4h"; |
| case ShortName::kVec4I: |
| return out << "vec4i"; |
| case ShortName::kVec4U: |
| return out << "vec4u"; |
| } |
| return out << "<unknown>"; |
| } |
| |
| } // namespace tint::type |